Repository navigation
fix: keep alert id stable when labeling a solo sequence FP - #584
Conversation
When a sequence labeled non-wildfire is the only one in its alert, the previous logic detached it, deleted the alert (now empty), and created an identical replacement — changing the alert id for no gain. Multi-sequence alerts still split so the FP no longer contributes to triangulation.
Adds an integration test asserting the alert id is preserved when labeling a single-sequence alert as non-wildfire, and a unit test for the same path. Updates the existing multi-sequence unit test to mock the new siblings probe.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #584 +/- ##
==========================================
+ Coverage 89.80% 90.11% +0.30%
==========================================
Files 55 55
Lines 2422 2508 +86
==========================================
+ Hits 2175 2260 +85
- Misses 247 248 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fe51
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR @MateoLostanlen ! tested and work on devenv
Just a comment and suggestion, not blocking but wondering of would more relevant. Actually, current isolation is probably fine but worth tightening since the fix is trivial. Tell me what do you think
| alerts_res = await detection_session.exec(select(Alert).execution_options(populate_existing=True)) | ||
| alerts_rows = alerts_res.all() | ||
| assert [row.id for row in alerts_rows] == [original_alert_id] |
There was a problem hiding this comment.
The two assertions query the entire Alert and AlertSequence tables, so they implicitly assume no other rows exist in the DB at that point. If test isolation ever weakens (shared fixtures, parallel runs, leftover data), these will fail for the wrong reason.
Scoping both queries to the sequence under test makes them resilient to whatever else is in the DB:
Fetches only AlertSequence rows for THIS sequence, checks it still points to the original alert
| alerts_res = await detection_session.exec(select(Alert).execution_options(populate_existing=True)) | |
| alerts_rows = alerts_res.all() | |
| assert [row.id for row in alerts_rows] == [original_alert_id] | |
| alert_links_res = await detection_session.exec( | |
| select(AlertSequence.alert_id).where(AlertSequence.sequence_id == seq.id)... | |
| ) | |
| assert set(alert_links_res.all()) == {original_alert_id} | |
|
Thanks @fe51 I added your change |
LIMIT 1siblings probe and the alert is left untouched.