zjncs opened a new pull request, #4124:
URL: https://github.com/apache/rocketmq-dashboard/pull/4124
### Motivation
`NativeAlertProcessor.reconcileMissingActiveStates` keeps rules whose stored
metric has surrounding whitespace by normalizing before matching the scope keys:
```java
.filter(rule ->
scope.metricKeys().contains(StringUtils.trimWhitespace(rule.getMetric())))
```
…but the `MybatisPlusAlertStateRepository.findActive` it then calls filters
with the **raw** value:
```java
.filter(rule -> metricKeys.contains(rule.getMetric()))
```
For a rule whose stored metric is padded (legacy rows — current write paths
trim, but the rule entities are documented to support values "copied from older
deployments", and `AlertRuleSemanticFingerprintTest` pins ` metric("
consumer.lag.total ")` as a supported input), the processor keeps the rule
while `findActive` drops it → `scopedRules` is empty → `findActive` returns
`List.of()` → `reconcileMissingActiveStates` sees no active states → the stale
FIRING/ACKED state is never resolved and no recovery notification is sent. This
silently reintroduces the exact failure mode the reconcile logic guards
against, via a caller/callee normalization mismatch.
### Modifications
`findActive` applies `StringUtils.trimWhitespace(...)` to the metric before
the `metricKeys` membership check, matching its only caller.
### Verification
New test `findsActiveStatesForRulesWithPaddedStoredMetricsTest` (model:
`findsActiveStatesWithLabelsFromTheLatestAlertEventTest`): rule with `.metric("
consumer.lag.total ")`, scope keys `Set.of("consumer.lag.total")`.
- Before the fix: fails — `Expected size: 1 but was: 0` (active states
empty).
- After the fix: passes — the FIRING state is returned with its key.
- Regression: `mvn -f server/pom.xml test
-Dtest='MybatisPlusAlertStateRepositoryTest,NativeAlertProcessorTest'` →
**Tests run: 23, Failures: 0, Errors: 0**.
--
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]