unbridled-41 opened a new issue, #5476:
URL: https://github.com/apache/rocketmq-dashboard/issues/5476
### Studio Version
branch: `rocketmq-studio` @ `6a68042f` (the revision verified; the branch is
based on it)
deployed as: built from source (unit test)
### Runtime Environment
Not environment-specific: frontend payload construction.
### Connected RocketMQ Cluster
Not cluster-specific; any instance with a native-metric rule (e.g. 消费积压总量).
### Describe the Bug
The rule form resolves the threshold unit while the metric is picked — the
native catalog supplies `messages`/`seconds` and the ratio metrics carry `%` —
but `attachThresholdUnit` re-derived it from a map that only knows the five
built-in metric names, so it submitted `''`. Saving a native-metric rule
therefore stored an empty unit: the rule list renders `> 12000` with no unit
and a notification template's `${thresholdUnit}` expands to nothing.
`thresholdUnitLabel` already knows how to render `messages`/`seconds`; it
simply never received them.
### Steps to Reproduce
1. Open Ops → Alerts → 新建规则, pick an instance and a native metric (the input
shows its unit).
2. Enter a threshold and save.
3. Observe the rule row renders the threshold without any unit; editing the
same rule shows the unit again, because the form re-derives it.
### What Did You Expect to See?
The saved rule carries the unit shown at authoring time.
### What Did You See Instead?
The unit is dropped.
### Evidence
- `web/src/pages/ops/alerts.tsx` (the metric's `thresholdUnit` and the
input's `addonAfter`), `web/src/pages/ops/alertRulePayload.ts`
(`attachThresholdUnit`), `ops/alert/NativeAlertMetricCatalogService.java` (the
catalog units).
- `cd web && npx vitest run src/pages/ops/__tests__/alertRulePayload.test.ts
src/pages/ops/__tests__/alerts.test.ts` — the added cases fail before the
change (`expected '' to be '%'`) and pass after (`Tests 8 passed`); the
pre-existing overwrite test still passes, so a stale unit can still not survive
a metric change.
### Impact
The saved rule loses the unit in the list and in notification templates.
### Acceptance Criteria
- The form's unit reaches persistence, while the built-in map stays
authoritative for the names it knows.
- Regression coverage for the payload builder — this change adds
`web/src/pages/ops/__tests__/alertRulePayload.test.ts`, which is what #4028
asked for.
**Corresponding PR:** #5447
--
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]