unbridled-41 opened a new issue, #5890:
URL: https://github.com/apache/rocketmq-dashboard/issues/5890

   ### Studio Version
   branch: `rocketmq-studio` @ `7e7aa344` (the revision verified; the branch is 
based on it)
   deployed as: not required to reproduce
   
   ### Runtime Environment
   
   Reproduced with the frontend tests (`cd web && npx vitest run 
src/pages/ops/__tests__/AlertsPage.test.tsx`); the browser locale does not 
matter.
   
   ### Connected RocketMQ Cluster
   
   Not involved.
   
   ### Describe the Bug
   
   A native alert rule stores its threshold unit as the metric catalog's code, 
because that is what the API round-trips (`NativeAlertMetricCatalogService`: 
`"messages"` for `consumer.lag.total`, `topic.backlog.total`, 
`dlq.message.count`, `"seconds"` for `consumer.delay.seconds`, `"ratio"`/`"%"` 
for the usage ratios).
   
   The rule dialog translates it for the threshold field's suffix 
(`thresholdUnitLabel` -> `alerts.unitMessages` = 条/messages, 
`alerts.unitSeconds` = 秒/seconds), but the rules table concatenates the raw 
code:
   
   ```ts
   // web/src/pages/ops/alerts.tsx (before)
   return `${rule.operator} ${rule.threshold}${rule.thresholdUnit ?? ''}`;
   ```
   
   So the Cluster and Business Alerts pages show
   
   ```
   > 12000messages
   > 420seconds
   ```
   
   in both languages, for the very rules whose own edit dialog renders `> 12000 
条` / `> 420 秒`. The same field disagrees between the list and the dialog that 
edits it, and an internal catalog code leaks into the UI.
   
   ### Steps to Reproduce
   
   1. On a native-metric instance, create a business rule on `Consumer lag 
total` with threshold 12000 (the dialog offers no unit choice; the catalog's 
unit is applied automatically).
   2. Look at the rule's row on the Business Alerts page: the condition column 
reads `> 12000messages`.
   3. Open the rule: the threshold field renders `12000 条`.
   
   ### What Did You Expect to See?
   
   The same unit the dialog shows for that field, translated in the active 
language.
   
   ### What Did You See Instead?
   
   The raw catalog code, glued to the number.
   
   ### Evidence
   
   - `web/src/pages/ops/alerts.tsx` - `formatThresholdCondition` (the table 
cell) vs the dialog's `thresholdUnitLabel` / `addonAfter`.
   - 
`server/src/main/java/org/apache/rocketmq/studio/ops/alert/NativeAlertMetricCatalogService.java:36-44`
 (the unit codes).
   - `web/src/i18n/translations.ts:1175-1177` (`alerts.unitMessages`, 
`alerts.unitSeconds`, `alerts.unitRatio` exist and are used only by the dialog).
   - `cd web && npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx` - 
before the fix the new cases report `expected '> 12000 条' to be '> 
12000messages'`.
   
   ### Impact
   
   Every native business rule that carries a unit renders an untranslated code 
in the rules table - the page operators scan for the lag/backlog/delay rules - 
while the dialog for the same rule shows the label, so the same field reads two 
different ways.
   
   ### Acceptance Criteria
   
   - Both surfaces render the unit through one shared mapping, with the percent 
sign still attached to the number and a word unit separated from it, and a 
regression test that pins the table cell and the mapping.
   - Rules without a unit and legacy ratio rules without a stored unit render 
exactly as before.
   
   **Corresponding PR:** #5890


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