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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6779
   
   ### Brief Description
   
   `#6451` tightened `AlertRuleRequestDTO.duration` to the Prometheus duration 
syntax
   (`PROMETHEUS_DURATION_REGEXP`: each unit at most once, descending) but left 
the second duration
   field of the same DTO, `reminderInterval`, on the expression it replaced
   (`AlertRuleRequestDTO.java:63`). Both fields are parsed by the same 
`AlertRuleDuration`, so the
   REST create/update endpoints of both alert domains accepted `1m1m`, `1s1m` 
or `1h2d` on the
   interval while rejecting them on the duration: `AlertRuleDuration.parse` 
checks only that the
   unit matches are adjacent and sums them, so a stored `1m1m` scheduled the 
next reminder two
   minutes later, and the rules table rendered the raw string — a value the 
editor's own interval
   list (5m / 15m / 30m / 1h / 4h) does not offer.
   
   Point `reminderInterval` at `PROMETHEUS_DURATION_REGEXP` so both duration 
fields of a rule
   validate the same syntax. A value the console can produce is unaffected.
   
   ### How Did You Test This Change?
   
   ```
   cd server && mvn -B -ntp test -DforkCount=1 
-Dtest=AlertRuleRequestDTOTest,AlertServiceTest
   Tests run: 31, Failures: 0, Errors: 0, Skipped: 0  -- AlertRuleRequestDTOTest
   Tests run: 100, Failures: 0, Errors: 0, Skipped: 0 -- AlertServiceTest
   Tests run: 131, Failures: 0, Errors: 0, Skipped: 0  (checkstyle:check green 
in the same run)
   ```
   
   The new tests fail without the fix — the interval field produced no 
violation for exactly the
   inputs the duration field rejects:
   
   ```
   
AlertRuleRequestDTOTest.reminderIntervalShouldRejectUnorderedOrRepeatedUnitsTest(String)[1-5]
   Expecting actual:
     []
   to contain exactly (and in same order):
     ["reminderInterval"]
   Tests run: 31, Failures: 5, Errors: 0, Skipped: 0
   ```
   
   ### Other consumers
   
   `reminderInterval` reaches the runtime through `AlertRuleDuration.parse` 
only; this change
   touches the request contract, not the stored format:
   
   | Surface | Status |
   | --- | --- |
   | `POST /api/alert-rules/{create,update}` and 
`/api/cluster-alert-rules/{create,update}` | fixed: they share 
`AlertRuleRequestDTO` and its bean validation |
   | Rule transfer import (`/import`) and the AI tool `rmq.alert.create` | 
unchanged by design: both build the DTO in code and go through 
`NativeAlertRulePolicy.validate`, which still parses (and therefore accepts) a 
reordered interval — the same scope `#6451` chose for `duration` |
   | Stored rules | unchanged: existing values keep their meaning (`1m1m` is 
still read as two minutes); no migration |
   | `AlertStateMachine` reminder scheduling | unchanged: it reads the stored 
string through `AlertRuleDuration.parse` |
   | Prometheus rule export | not affected: the export writes `duration` only, 
never the reminder interval |
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`feat:` / `fix:` / 
`refactor:` / `chore:` / `docs:` / `perf:`)
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [ ] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   


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