Wang1rrr opened a new pull request, #4872:
URL: https://github.com/apache/rocketmq-dashboard/pull/4872
### Which Issue(s) This PR Fixes
- Fixes #4870
### Brief Description
The server already reports when the body it returns is not the whole body,
`docs/api-spec.md` §8.1 documents those fields in its `#### MessageRecord`
table (`:1336` `bodyEncoding`, `:1337` `bodyTruncated`, `:1342`
`propertiesTruncated`), and the console discards them anyway.
`RocketMQMessageProvider.displayBody` (`:881`-`:903`) cuts a UTF-8 body at 64
KiB and a non-decodable body at 48 KiB of base64, and `toRecordVO`
(`:867`-`:869`) puts both facts on `MessageRecordVO.bodyEncoding` /
`.bodyTruncated`. The web contract does not declare either field
(`web/src/api/message.ts:4`-`:19`), so the detail panel renders a partial or
base64 body under 消息体 with no marker, and 下载 writes it to `<msgId>.json`.
- `web/src/api/message.ts` - `MessageRecord` gains `bodyEncoding?: string |
null` and `bodyTruncated?: boolean`, each with a comment naming the server
field and the 64 KiB / 48 KiB caps it mirrors
- `web/src/pages/instance/message.tsx` - two notices between the 消息体 heading
and the body block: a `warning` Alert when `bodyTruncated`, an `info` Alert
when `bodyEncoding === 'BASE64'`. Both reuse the page's existing Alert idiom
(`:1221` for `resultMayBeTruncated`) and neither renders for a complete UTF-8
body
- `web/src/i18n/translations.ts` - `messagePage.bodyTruncatedWarning` and
`messagePage.bodyBinaryWarning`, zh and en, next to the existing
`messagePage.truncatedWarning`
- `web/src/pages/instance/__tests__/MessagePage.test.tsx` - two cases
following the existing detail-panel tests
This is the half of the problem #4777 explicitly left open ("It does not
recover backend-truncated or encoded data"): the data cannot be recovered
because the server never sent it, so the fix is to stop implying it did.
Scope kept deliberately narrow:
- the panel shows no message **properties** at all today, so
`propertiesTruncated` is not added here - it belongs with a properties table,
which is a separate change
- the download filename/MIME for a base64 body stays as it is; that is
#4777's territory, and this PR does not touch `handleDownload`
- `storeTime: number | string` on the same interface is left alone
### How Did You Test This Change?
```
cd web
npx vitest run src/pages/instance/__tests__/MessagePage.test.tsx
Test Files 1 passed (1)
Tests 16 passed (16) # 14 pre-existing + 2 new
npx tsc -b # exit 0
npx eslint src/api/message.ts src/i18n/translations.ts
src/pages/instance/message.tsx src/pages/instance/__tests__/MessagePage.test.tsx
# exit 0, no findings
npx prettier --check --end-of-line auto <the same four files>
All matched files use Prettier code style!
```
Mutation-checked, because a warning that is never asserted is easy to lose.
Deleting both Alert blocks from the detail panel and re-running fails exactly
the new positive case and nothing else:
```
npx vitest run src/pages/instance/__tests__/MessagePage.test.tsx
x warns on the detail panel when the body was truncated or is not text
Test Files 1 failed (1)
Tests 1 failed | 15 passed (16)
```
Restoring the blocks returns the file to `16 passed (16)`.
The negative case pins the other direction: a message with `bodyEncoding:
'UTF-8'` and `bodyTruncated: false` must render no `role="alert"` at all in the
panel, so the notices cannot degrade into permanent noise.
Both new strings are zh+en pairs under the existing `messagePage.`
namespace, which is what the translation invariant test in #4809 checks; that
PR is not merged yet, so the keys were verified by reading them back out of
`translations.ts` and by the rendered-text assertions in the new tests (the
test asserts the literal Chinese string, so a missing or renamed key fails the
suite).
No Java changed, so `mvn test` and the ArchUnit checks are unaffected.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test` (web: two new vitest cases, mutation-checked both ways)
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks) - no Java changed
- [x] New source files carry the ASF license header (no new source files)
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help) - `docs/api-spec.md` §8.1 already documents `bodyEncoding` /
`bodyTruncated` / `propertiesTruncated` (`:1336`-`:1342`), so this change moves
the web layer towards the documented contract and no doc edit is needed
--
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]