unbridled-41 opened a new pull request, #4746:
URL: https://github.com/apache/rocketmq-dashboard/pull/4746
Fixes #4745.
## Problem
A message trace looked up by **Message Key** keeps the broker's raw node
status, so a failed node renders and scores as healthy. `GET
/messages/trace-by-key` returns the same nodes as `GET /messages/{msgId}/trace`
(both go through `parseTraceBody`, which emits only `"finish"`/`"failed"`), but
only the message-id wrapper normalised the status through `mapTraceNodeStatus`
at the API boundary.
- `web/src/api/message.ts:150-156` — the mapper, documented as "Map at the
API boundary so the UI never sees a status it cannot render".
- `web/src/api/message.ts:172-179` — applied on the message-id path.
- `web/src/api/message.ts:200-201` (before this change) —
`getMessageTraceByKey` returned `res.data.data` verbatim.
- `web/src/pages/instance/message.tsx:646-654` — both lookups feed the same
`setTraceData(result)`; `:1003` passes `status: node.status` to `Steps`, and
`web/src/utils/messageTraceDiagnostics.ts:220-229` only treats `'error'` as a
failed phase.
## Root cause
The status mapping lives in the message-id wrapper instead of a shared
response normaliser, so the key lookup added in #2520 (`96ad1b06`) never
received the mapping introduced by #2576 (`8c0079be`) for the other lookup.
## Fix
`getMessageTraceByKey` now maps its nodes through the same
`mapTraceNodeStatus` and keeps the existing `null` (no trace found) contract.
12 lines changed in `web/src/api/message.ts`, no behaviour change for the
message-id path.
## Tests
Red before the fix (`web/src/api/message.test.ts`, new case "maps backend
trace node statuses on the key lookup too"):
```
AssertionError: expected [ Array(3) ] to deeply equal [ 'error', 'finish',
'wait' ]
- Expected + Received
[ - "error" + "failed", "finish", - "wait" + "something-else" ]
```
Commands and results after the fix, run from `web/`:
- `npx vitest run src/api/message.test.ts --maxWorkers=2` → **8 passed** (1
file).
- `npx vitest run src/pages/instance/__tests__/MessagePage.test.tsx
src/pages/instance/__tests__/MessagePageAsyncState.test.tsx
src/api/message.test.ts src/utils/messageTraceDiagnostics.test.ts
--maxWorkers=2` → **45 passed** (4 files), including the pre-existing "keeps
the current trace loading when an earlier trace finishes first" race coverage.
- `npx tsc -b` → clean; `npx eslint src/api/message.ts
src/api/message.test.ts` → clean.
## Duplicate check
Searched open PRs and issues for `trace`, `trace-by-key`,
`getMessageTraceByKey`, `node`, `step status`, `failed`: the only hits are
#4483/#3297 (bound the trace request cache), #3305 (`NO_MESSAGE` grading for
empty lookups) and #2520/#2576 in history (the two commits that introduced the
two halves). No open item covers the by-key status mapping.
## Base branch
Targets the development trunk `rocketmq-studio` (AGENTS/CONTRIBUTING for
this repository). GitHub interprets closing keywords only for pull requests
that target the repository default branch, and that is still `master`, so
merging will not close #4745 automatically — it needs to be closed by hand.
## Risk
Low: the change only adds a status normalisation to one wrapper and mirrors
the sibling function; the response shape, the `null` contract and the request
parameters are untouched.
--
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]