You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "unbridled-41 (via GitHub)" <gi...@apache.org> on 2026/10/09 16:33:18 UTC

[I] [Bug] Alert notification templates render large ${value}/${threshold} values in scientific notation [rocketmq-dashboard]

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

   ### 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 backend unit tests (`cd server && mvn -o -B -ntp test -Dtest='AlertNotificationTemplateTest'`), which need no MySQL and no cluster. The delivered text is produced by the same renderer in production; the notification channel does not matter.
   
   ### Connected RocketMQ Cluster
   
   Not involved. The value comes from the alert's own collected sample.
   
   ### Describe the Bug
   
   `AlertNotificationTemplate` renders `${value}` (for every metric except the percent branch) and `${threshold}` with `String.valueOf(double)`:
   
   ```java
   // server/src/main/java/org/apache/rocketmq/studio/ops/alert/AlertNotificationTemplate.java
   values.put("threshold", rule == null ? "" : String.valueOf(rule.getThreshold()));
   ...
   return String.valueOf(currentValue);      // non-ratio branch
   ```
   
   `Double.toString` switches to computerized scientific notation at 1e7, so a consumer-lag alert whose current value is 12,500,000 - the number these alerts exist for - is delivered as
   
   ```
   [warning] Consumer lag high - 1.25E7 messages pending
   ```
   
   The rule dialog shows the operator something else. Its live preview builds the same variables with JavaScript `String(context.value)` (`web/src/utils/alertTemplatePreview.ts`), which prints `12500000`, and the threshold unit is appended verbatim, so the delivered text reads `1.25E7messages`. The same file already fixed exactly this divergence for the percent branch, with a comment naming the artifact ("plain double arithmetic renders the stored 0.29 as 28.999999999999996").
   
   ### Steps to Reproduce
   
   1. Create a business alert rule on `consumer.lag.total` with a notification template containing `${value}` and `${threshold}`, threshold 12000000.
   2. Let the collected value exceed 12,500,000 (or call `AlertNotificationTemplate.render` with `currentValue = 12500000.0`).
   3. Read the delivered DingTalk/SMS/email body: `1.25E7/1.2E7messages`.
   
   ### What Did You Expect to See?
   
   The same decimal the rule dialog previews for those variables, e.g. `12500000/12000000messages`.
   
   ### What Did You See Instead?
   
   Computerized scientific notation, which an operator reading a phone notification can easily misread, and which does not match the preview shown next to the template field.
   
   ### Evidence
   
   - `server/src/main/java/org/apache/rocketmq/studio/ops/alert/AlertNotificationTemplate.java` (`values()` line 54, `formattedValue()` tail).
   - `web/src/utils/alertTemplatePreview.ts` (`value: String(context.value ?? defaultContext.value)`).
   - `cd server && mvn -o -B -ntp test -Dtest='AlertNotificationTemplateTest'` - the new case reports `expected: "12500000/12000000messages" but was: "1.25E7/1.2E7messages"` before the fix.
   
   ### Impact
   
   Any rule whose custom template interpolates the measurement and whose value reaches 1e7 - consumer lag and topic backlog are exactly that - delivers a notification that contradicts the preview the operator approved. Values below 1e7 are unaffected.
   
   ### Acceptance Criteria
   
   - `${value}` and `${threshold}` render in plain decimal for finite values (the percent branch keeps its existing exact-decimal behaviour), with a regression test that pins a 1e7-scale value and a non-finite one.
   - Values that already rendered correctly (including the pinned `86.5%/85.0` and `Disk warning: 86.0 on local`) render exactly as before.
   
   **Corresponding PR:** #5888


-- 
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: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Alert notification templates render large ${value}/${threshold} values in scientific notation [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed issue #5888: [Bug] Alert notification templates render large ${value}/${threshold} values in scientific notation
URL: https://github.com/apache/rocketmq-dashboard/issues/5888


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Alert notification templates render large ${value}/${threshold} values in scientific notation [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on issue #5888:
URL: https://github.com/apache/rocketmq-dashboard/issues/5888#issuecomment-6443358865

   Resolved by #5918 (merged into `rocketmq-studio` as `2df0a70e1`). The fix was originally submitted in #5889 and consolidated into that commit.


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org