Frun1na opened a new pull request, #5649:
URL: https://github.com/apache/rocketmq-dashboard/pull/5649

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5648
   
   ### Brief Description
   
   Cloud providers reported a fabricated `0` as the message size whenever the 
vendor API does not return one, and the message page rendered it as `0 B` — 
indistinguishable from "this message is empty":
   
   - `TencentInstanceProvider` set `.size(0)` on both the `DescribeMessage` and 
`MessageItem` paths.
   - `AliyunConverters.toMessageRecord` set `.size(data.getBodySize() == null ? 
0 : data.getBodySize())`.
   
   `MessageRecordVO` now documents and exports the unknown sentinel 
(`UNKNOWN_SIZE = -1`), both cloud adapters report it instead of a zero, and the 
web side renders the sentinel as `-`.
   
   On the web the shared `formatBytes` renders negative numbers with a minus 
sign by design (its own tests pin `-1536 → -1.5 KB`), so the sentinel is mapped 
before formatting: a page-local `formatMessageSize` that returns `-` for 
negative sizes and delegates to `formatBytes` otherwise, used by both the 
table's Size column and the detail panel.
   
   ### How Did You Test This Change?
   
   Server — the two new assertions fail on the unpatched providers (`expected: 
-1`) and pass with the fix:
   
   ```
   $ cd server && mvn -B -ntp test 
-Dtest='TencentInstanceProviderTest#queryMessagesByMsgIdShouldReportUnknownSizeTest,AliyunConvertersBodyEncodingTest'
 -DforkCount=1
   # unpatched providers:
   [ERROR] 
TencentInstanceProviderTest.queryMessagesByMsgIdShouldReportUnknownSizeTest:960 
expected: -1
   [ERROR] 
AliyunConvertersBodyEncodingTest.shouldReportUtf8WhenTheBase64BodyDecodesToText:53
 expected: -1
   Tests run: 6, Failures: 2, Errors: 0, Skipped: 0
   
   # with the fix:
   $ cd server && mvn -B -ntp test 
-Dtest='AliyunConvertersBodyEncodingTest,TencentInstanceProviderTest' 
-DforkCount=1
   Tests run: 61, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   Web — the new test fails on the unpatched page (`-1 B` leaked into the 
table) and passes with the fix:
   
   ```
   $ cd web && npx vitest run src/pages/instance/__tests__/MessagePage.test.tsx
    × renders an unknown message size as unavailable instead of 0 B   # 
unpatched page
   expected document not to contain element, found <td ...>
   
   $ cd web && npx vitest run src/pages/instance/__tests__/MessagePage.test.tsx
    ✓ src/pages/instance/__tests__/MessagePage.test.tsx (27 tests) 19.54s
    Test Files  1 passed (1)
         Tests  27 passed (27)
   ```
   
   ### 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`
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [x] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   
   ---
   
   Re-submission of #5086: the original PR was closed by the stale bot after 7 
days without review activity, and GitHub rejects reopening pull requests in 
this repository ("state cannot be changed"), so the same change is re-submitted 
rebased onto the current `rocketmq-studio` tip (`6a68042f`), adapted to the 
shared byte-size formatter that has since landed in `web/src/utils/format.ts`. 
The original thread stays available at #5086.
   


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