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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]