iloveeyjafjalla opened a new pull request, #6855: URL: https://github.com/apache/rocketmq-dashboard/pull/6855
Fixes #6854 ## The defect The transfer upload posts the parsed document unchanged, while the server validates every rule in it with the canonical duration pattern (`AlertRuleRequestDTO.java:41`, reached through `AlertRuleTransferDTO.rules` with `@Valid`). A file exported from a store that still holds a pre-canonical label (`5分钟` — the dictionary `alertRulePayload.ts:26-31` and `AlertRuleSemanticFingerprint.java:36-37` both expect such rows) is therefore answered with `400 duration is invalid`, and because the validation covers the whole document, none of its rules is imported. ## The fix `handleImportRules` maps the parsed document through the same dictionary the rule editor already uses when it opens such a rule (`normalizeDuration`), so the upload carries the canonical value the server accepts. The document is otherwise untouched — the version/domain/rules guard stays, and only the duration is canonicalized: it is the one field the import validates and the store can hold in legacy form (a metric expression is not validated, and rewriting it would change what the rule evaluates). ## Tests Red before the fix: ``` FAIL src/pages/ops/__tests__/AlertsPage.test.tsx > maps the legacy duration of an imported rule document to its canonical value AssertionError: expected '5分钟' to be '5m' ``` The test uploads a `version: 1` document whose single rule carries `"duration":"5分钟"` and asserts the payload that reaches `importAlertRulesTransfer` carries `5m`. Green after, with the gates: ``` Test Files 1 passed (1) Tests 36 passed (36) tsc -b exit 0 eslint exit 0 (no errors; the 5 warnings in alerts.tsx predate this change) prettier --check All matched files use Prettier code style! ``` -- 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]
