iloveeyjafjalla opened a new issue, #6854:
URL: https://github.com/apache/rocketmq-dashboard/issues/6854
## Summary
Alerts → 导出 writes a JSON document that Alerts → 导入 then refuses to restore,
when the deployment's rule store still holds a pre-canonical duration label.
The upload is answered with `400 duration is invalid`, and because the server
validates the document as a whole, **no** rule of the file is imported — not
even the ones that are valid.
## Why
- The client posts the parsed document unchanged:
`web/src/pages/ops/alerts.tsx:455-459` (`JSON.parse(await file.text()) as
AlertRuleTransfer` → `importAlertRulesTransfer(transfer, domain)`).
- The server validates every rule with the canonical duration pattern —
`AlertRuleRequestDTO.java:41` (`@Pattern(regexp = PROMETHEUS_DURATION_REGEXP,
message = "duration is invalid")`) — reached from `AlertRuleTransferDTO.rules`
through `@Valid` on the controller, so `AlertRuleTransferService.importRules`
never runs.
- The duration is copied verbatim from the stored rule
(`AlertRuleTransferService.toRequest`), and the console knows that stored rules
can still carry the older labels: `web/src/pages/ops/alertRulePayload.ts:26-31`
maps `1分钟/5分钟/15分钟/30分钟` to `1m/5m/15m/30m`, and the editor applies that map
when a rule is opened for editing (`alerts.tsx:502-503`). The backend states
the same expectation about such rows in
`AlertRuleSemanticFingerprint.java:36-37` ("Legacy external rules may contain
invalid text").
## Impact
Export is how rules are backed up and moved between deployments, so a store
with one such row produces a file that cannot be restored anywhere, and the
console reports a validation failure instead of the rules it did contain. The
same applies to a document that was hand-edited or produced by an older Studio.
## Reproduction
`web/src/pages/ops/__tests__/AlertsPage.test.tsx` → `maps the legacy
duration of an imported rule document to its canonical value` uploads this file:
```json
{"version":1,"domain":"CLUSTER","rules":[{"name":"Legacy
lag","metric":"broker.disk.usage","operator":">","threshold":85,"duration":"5分钟","channels":["dingtalk"],"enabled":true}]}
```
Before the fix the payload that reaches `importAlertRulesTransfer` still
carries `5分钟`:
```
AssertionError: expected '5分钟' to be '5m'
```
## Expected
The document imports, with the legacy label canonicalized the same way the
rule editor canonicalizes it, and the valid rules in the file are restored.
--
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]