fix(rulesengine): report matched sub-rules as written - #6695
Conversation
Signed-off-by: chiruu12 <103719146+chiruu12@users.noreply.github.com>
shahargl
left a comment
There was a problem hiding this comment.
Can u add tests to cover it?
…tion rule Signed-off-by: chiruu12 <103719146+chiruu12@users.noreply.github.com>
|
Added There was already a unit test in
|
|
Tests are pushed at f34b686 and CI is green. Ready for another look when you have time. |
|
@shahargl tests are in. I pushed them as Two of them, covering both levels:
Both fail on the commit before the fix and pass on it. Ready for another look. |
Fixes #6694
_check_if_rule_applyrewrotenullto""by rebinding the loop variable, then appended that rewritten string as the sub-rule that matched._process_event_for_history_based_rulecompares those against sub-rules taken fromrule.definition_cel, which still saysnull, so the sets could never be equal. Correlation rules withcreate_on: alland a null-bearing definition never reachedis_all_conditions_met, so the incident was never made visible and the created event never fired.The rewrite now happens on a separate variable, so evaluation is unchanged and the sub-rule is reported as written. The length check at line 158 was already unaffected, since it compares counts, so the single-alert case behaved correctly before and still does.
Added a regression test alongside the existing
_check_if_rule_applycoercion test. It feeds two alerts to(source == "sentry") || (service != null), one satisfying each side, and asserts the matched set equals the extracted sub-rules. It fails on main and passes here.pytest tests/test_alert_evaluation.pyis green, 21 passed.