[Bug] Validate topK in Lite group info queries
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 27
Description
### Runtime platform environment
Windows, local broker unit tests; no running cluster is required for the regression test.
### RocketMQ version
`develop` at `ff8f6f74c560e391261ccd716707c6d20422e253` (5.5.1).
### JDK Version
Amazon Corretto 8u482; Maven 3.9.11.
### Describe the Bug
`LiteManagerProcessor.getLiteGroupInfo` forwards the request's `topK` directly to the lag calculators when `liteTopic` is absent or empty. `GetLiteGroupInfoRequestHeader.checkFields()` does not validate it.
`LiteConsumerLagCalculator.getLagCountTopK` uses `topK` as the initial capacity of a `PriorityQueue`. Zero and negative values are invalid constructor arguments. Large positive values also control the initial backing-array allocation without a server-side bound.
### Steps to Reproduce
1. Use an existing Lite consumer group bound to a parent topic.
2. Send `GET_LITE_GROUP_INFO` with that group, no specific `liteTopic`, and `topK=0` or `topK=-1`. The equivalent CLI input is `mqadmin getLiteGroupInfo -n -p -g -k 0`.
3. The processor reaches `getLagCountTopK` instead of rejecting the invalid parameter.
The accompanying processor regression test serializes request headers and invokes `processRequest`. It fails on the unmodified implementation because the invalid request reaches the mocked lag calculator. The constructor behavior above is established from the source path; a live-cluster run and large allocations were not attempted.
### What Did You Expect to See?
An `INVALID_PARAMETER` response with a clear valid range, before calling either lag calculator. Requests for a specific LiteTopic should continue to work without `topK`, since that path does not use it.
### What Did You See Instead?
The aggregate query accepts an unchecked heap capacity and reaches the calculator instead of returning a parameter error.
### Additional Context
A small fix can reuse the processor's existing `MAX_RETURN_COUNT` (10,000), accepting `topK` in `[1, 10000]` for aggregate queries. Regression coverage includes null/empty LiteTopic, zero/negative/oversized values, accepted boundaries, and a specific-topic query with the default `topK`.
I searched existing issues and pull requests for `topK` and the Lite lag calculator; the related merged PR #10424 optimizes timestamp lookup and does not add this validation.
Contributor guide
Research direction
Start with LiteManagerProcessor.getLiteGroupInfo and GetLiteGroupInfoRequestHeader.checkFields(), then inspect the existing MAX_RETURN_COUNT and lag-calculator calls. Run the processor regression test that serializes request headers and invokes processRequest. Done means aggregate queries reject topK outside 1–10,000 before either calculator runs, while specific-topic queries still work without topK.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100