NUAAwqy opened a new pull request, #7301:
URL: https://github.com/apache/rocketmq-dashboard/pull/7301
### Which Issue(s) This PR Fixes
- Fixes #7174
### Brief Description
`formatBody` in `web/src/pages/instance/message.tsx` pretty-prints JSON
message bodies with `JSON.parse` + `JSON.stringify`, which round-trips every
number through an IEEE-754 double and rewrites tokens the payload never
contained (int64 beyond `Number.MAX_SAFE_INTEGER`, high-precision decimals,
exponent forms).
The fix extracts the numeric tokens from the raw body and from the formatted
output and falls back to showing the body verbatim whenever any token would
change. Bodies whose numbers round-trip byte-for-byte keep the existing
pretty-printed output, and non-JSON behavior is unchanged. `formatBody` is
exported (with a scoped `react-refresh` eslint-disable) so the new regression
test can target it directly.
### How Did You Test This Change?
```
$ cd web && npx vitest run
src/pages/instance/__tests__/FormatBodyNumericTokens.test.ts
src/pages/instance/__tests__/MessagePage.test.tsx --maxWorkers=1
Test Files 2 passed (2)
Tests 20 passed (20)
```
- `npx tsc -b` — clean
- `npx eslint src/pages/instance/message.tsx
src/pages/instance/__tests__/FormatBodyNumericTokens.test.ts` — 0 errors, 0
warnings
- New test covers all four cases from the report: `9007199254740993`,
`9223372036854775807` and `0.1234567890123456789012345` are preserved verbatim;
`42` still pretty-prints. Also covers digits inside strings, nested JSON and
non-JSON bodies.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`fix:`)
- [x] Tests added or updated for non-trivial changes
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no new UI text)
- [x] Architecture constraints stay green (frontend-only change; no
backend/ArchUnit surface touched)
- [x] New source files carry the ASF license header
- [x] Documentation touched where behaviour changed (no docs describe the
old rounding behavior; display now matches the copied/downloaded bytes)
AI disclosure: this change was drafted with assistance from an AI coding
agent, reviewed by the author, and verified with the commands pasted above.
--
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]