You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "btlqql (via GitHub)" <gi...@apache.org> on 2026/10/02 03:06:57 UTC
[PR] fix(message): grade a route-less topic as empty in the key query [rocketmq-dashboard]
btlqql opened a new pull request, #5317:
URL: https://github.com/apache/rocketmq-dashboard/pull/5317
### Which Issue(s) This PR Fixes
- Fixes #5286
### Brief Description
`RocketMQMessageProvider.queryByKey` (server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMessageProvider.java:253) graded only `ResponseCode.NO_MESSAGE` as a business-empty result. When the topic has no route (deleted topic, typo, route not published yet) `MQAdminImpl.queryMessage` fails locally with `ResponseCode.TOPIC_NOT_EXIST`, so the exception fell through to the `throw new BusinessException(502, "Failed to query messages by key: ...")` branch even though the query itself had completed with no business data. The topic-mode path (`queryByTopic`) already grades `TOPIC_NOT_EXIST` / `NO_MESSAGE` as empty, so the two query paths disagreed and the message page surfaced a gateway error for an empty result.
The fix adds `ResponseCode.TOPIC_NOT_EXIST` to the graded response codes in `queryByKey`, exactly like `queryByTopic`/the unique-key path already do, so the key query answers 200 with an empty list; genuine RPC failures (anything else) still become the 502 `Failed to query messages by key`.
### How Did You Test This Change?
New test `RocketMQMessageProviderTest#queryByKeyReturnsEmptyListWhenTheTopicRouteIsGone` mocks `adminExt.queryMessage("TopicA", "order-1", 64, 100L, 200L)` to throw `MQClientException(ResponseCode.TOPIC_NOT_EXIST, "No route info of this topic: TopicA")` and asserts `provider.queryMessages(...)` returns an empty list.
Red run on the unmodified tree:
```
$ cd server && mvn -B -ntp test -Dtest=RocketMQMessageProviderTest
[ERROR] Errors:
[ERROR] RocketMQMessageProviderTest.queryByKeyReturnsEmptyListWhenTheTopicRouteIsGone:345->lambda$setUp$0:116 ? Business Failed to query messages by key: CODE: 17 DESC: No route info of this topic: TopicA
[INFO]
[ERROR] Tests run: 62, Failures: 0, Errors: 1, Skipped: 0
[INFO] BUILD FAILURE
```
Green run after the fix (same command, same test class):
```
$ cd server && mvn -B -ntp test -Dtest=RocketMQMessageProviderTest
[INFO] Tests run: 62, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.768 s -- in org.apache.rocketmq.studio.provider.apache.RocketMQMessageProviderTest
[INFO] Tests run: 62, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
`mvn` also runs checkstyle at `validate`; both runs report `You have 0 Checkstyle violations.`
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes
- [x] New UI text has both Chinese and English entries under `web/src/i18n/` — not applicable, no UI text changed
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit checks) — the touched module's own test class plus its ArchUnit checks run in the same reactor; no layer/package dependency changed
- [x] New source files carry the ASF license header — no new source file, only an existing test class and an existing method
- [x] Documentation touched where behaviour changed (README / `docs/` / in-app help) — not applicable: the change restores the documented "business-empty returns 200" contract, the API shape is unchanged and `docs/api-spec.md` is owned by another change
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(message): grade a route-less topic as empty in the key query [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #5317: fix(message): grade a route-less topic as empty in the key query
URL: https://github.com/apache/rocketmq-dashboard/pull/5317
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(message): grade a route-less topic as empty in the key query [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #5317:
URL: https://github.com/apache/rocketmq-dashboard/pull/5317#issuecomment-6094437906
The fix itself is correct: `RocketMQMessageProvider.java:253` is the only message-query catch block in the file that does not already grade `TOPIC_NOT_EXIST` as business-empty (`:449`, `:664`, `:713` and `RocketMQDLQProvider.java:538` all do), and your red/green evidence checks out line for line.
We are closing it as a duplicate of #5287, which changes the same line for the same issue (#5286) and was opened 11.7 hours earlier by the issue reporter; #5287 is itself a re-submission of #4918.
Two things worth carrying over to whichever patch lands, since neither PR has them: your description says the unique-key path already grades `TOPIC_NOT_EXIST`, but `queryMessageByUniqueKey` at `:294` grades only `NO_MESSAGE, QUERY_NOT_FOUND` and reaches the same 502 at `:300` — both of its branches end in `MQAdminImpl.queryMessage`, so a route-less topic fails there identically. Grading it in the same pass would close the family.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org