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

   ## Defect
   
   `formatThresholdCondition` in `web/src/pages/ops/alerts.tsx` renders legacy 
ratio rules (no `thresholdUnit`, threshold stored as a fraction) with plain 
double multiplication:
   
   ```ts
   if (nativeRatioMetrics.has(rule.metric) && !rule.thresholdUnit) {
     return `${rule.operator} ${rule.threshold * 100}%`;
   }
   ```
   
   For every binary-inexact fraction this leaks the IEEE-754 residue into the 
UI — a rule with `threshold: 0.29` renders as **`> 28.999999999999996%`** (0.07 
→ `7.000000000000001%`, 0.57 → `56.99999999999999%`).
   
   The backend already fixed this exact conversion in 
`AlertNotificationTemplate.formattedValue` using `BigDecimal.movePointRight(2)` 
— its comment literally names "plain double arithmetic renders the stored 0.29 
as 28.999999999999996" — but the web table's rendering path was not updated to 
match.
   
   ## Fix
   
   Round to one decimal place (`Math.round(x * 100 * 10) / 10`), mirroring the 
backend's stable formatting.
   
   ## Tests
   
   New `web/src/pages/ops/__tests__/alertsThresholdFormat.test.ts` (4 cases):
   
   - 0.29 / 0.07 / 0.57 / 0.58 → `29%` / `7%` / `57%` / `58%` (all failed on 
current master with the residue strings)
   - 0.85 control (the one value the existing suite happened to test, because 
0.85 × 100 is exact in double)
   - 0.295 → `29.5%` (non-integer percentage stays one-decimal stable)
   
   Verification: fail-before (2 failed) → pass-after (4/4) → mutation (bare 
multiply restored → residue failures return) → existing `AlertsPage.test.tsx` 
stays green (28/28), including its legacy-ratio rendering case.
   
   ## Collision check
   
   No open PR touches `formatThresholdCondition` or the threshold rendering 
lines; `#5397` touches a different function in the same file (notification 
delivery timestamps), no overlapping hunks.
   


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