unbridled-41 opened a new pull request, #3302:
URL: https://github.com/apache/rocketmq-dashboard/pull/3302

   # PR 2 — fix(message): treat MQClientException NO_MESSAGE key queries as 
empty results
   
   ## Problem / Evidence
   `MQAdminImpl.queryMessage` (rocketmq-client 5.5.0, verified in the resolved 
jar's bytecode) throws `MQClientException(ResponseCode.NO_MESSAGE=208, "query 
message by key finished, but no message.")` when the key matches nothing — it 
never returns an empty `QueryResult`. The Apache provider converts every 
exception into `BusinessException(502)`:
   
   - `GET /api/messages?...&key=<no-match>` → 502 "Failed to query messages by 
key: CODE: 208 ..." for a normal no-match outcome.
   - `GET /api/messages/{msgId}/trace` for a message without trace data (trace 
disabled on the producer or expired) → 502. The code's own grading convention 
comment says "the RPC succeeded but there is no business data, so return an 
empty trace instead of surfacing an error", but only `TOPIC_NOT_EXIST` is 
graded.
   
   Closed issues #1161/#1275 record the intended semantics: "A completed query 
with no matching messages may return an empty list. A remote query failure must 
return a structured gateway error." `NO_MESSAGE` is exactly a completed query 
with no matching records.
   
   ## Root cause / Fix
   `NO_MESSAGE` (client-side "no data" signal) is indistinguishable from remote 
failures in the catch-alls of `queryByKey`, `getMessageTrace`, and 
`getMessageTraceByKey`.
   
   Fix: shared `hasResponseCode(error, codes...)` helper (same cause-walk as 
the old `isTraceTopicAbsent`); `queryByKey` returns an empty list on 
`NO_MESSAGE`, both trace paths return an empty trace on `TOPIC_NOT_EXIST` or 
`NO_MESSAGE`. Genuine broker failures still surface as 502 (existing tests 
`queryByKeySurfacesAdminFailure`, `getMessageTraceSurfacesAdminFailure` 
unchanged and green).
   
   ## Priority & scoring
   PRIORITY 78 = 影响 30 (first-class query modes error out on normal empty 
outcomes) + 波及范围 14 (message query + trace paths, one provider) + 可复现性 19 
(deterministic; client behavior verified in bytecode and reproduced in red 
tests) + 维护价值 15 (aligns code with documented convention). FIX_CONFIDENCE 92.
   
   ## Tests
   - `mvn -Dtest=RocketMQMessageProviderTest test` → 39/39 (3 new tests red on 
pristine with exactly the production error `BusinessException: ... CODE: 208 
DESC: query message by key finished, but no message.`; green after fix).
   - Related modules (`org.apache.rocketmq.studio.provider.apache.*Test`, 
`org.apache.rocketmq.studio.instance.message.*Test`) → 299/299.
   - Full backend `mvn test`: see comment below.
   
   ## Risk
   Low. Only response-code 208 grading is added; error semantics for real 
failures unchanged.
   
   


-- 
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