tju-yxq opened a new issue, #1433:
URL: https://github.com/apache/rocketmq-dashboard/issues/1433

   ## Bug Report
   
   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Runtime platform environment
   
   OS: Ubuntu 20.04 / Any OS running RocketMQ Studio
   
   ### RocketMQ version
   
   branch: rocketmq-studio
   version: 5.3.2+
   Git commit id: f727341
   
   ### JDK Version
   
   OpenJDK 21
   
   ### Describe the Bug
   
   `RocketMQMessageProvider.queryMessages()` does not validate that `begin < 
end`. If a user accidentally provides `startTime` greater than `endTime`, the 
query proceeds with an inverted time range. Depending on the query type:
   
   - **KEY query**: `adminExt.queryMessage(topic, key, max, begin, end)` 
receives `begin > end`. The broker may return zero results or throw a confusing 
error.
   - **TOPIC query**: `searchOffset(queue, begin)` returns a higher offset than 
`searchOffset(queue, end)`, causing the pull loop's `offset <= maxOffset` 
condition to immediately fail, returning zero results with no explanation.
   
   The metrics query (`MetricsService.validateQueryWindow`) correctly validates 
`end > start` and rejects inverted ranges, but the message query has no such 
check.
   
   ### Steps to Reproduce
   
   1. Open RocketMQ Studio message query page.
   2. Set start time to `2026-08-10 12:00` and end time to `2026-08-10 10:00` 
(inverted).
   3. Query by topic.
   4. Observe: zero results with no error message explaining the time range is 
invalid.
   
   ### What Did You Expect to See?
   
   A clear error message: "Start time must be before end time" (HTTP 400).
   
   ### What Did You See Instead?
   
   Zero results with no explanation, making it appear as if no messages exist.
   
   ### Additional Context
   
   **Affected file**: 
`server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMessageProvider.java`,
 method `queryMessages()` at approximately line 100.
   
   **Fix**: Add a validation check after computing `begin` and `end`:
   
   ```java
   long end = endTime != null ? endTime : System.currentTimeMillis();
   long begin = startTime != null ? startTime : end - ONE_HOUR_MILLIS;
   if (begin >= end) {
       throw new BusinessException(400, "Message query start time must be 
before end time");
   }
   ```
   
   This is a 3-line fix.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to