feat(alerts): unmatch a sequence from an alert#582
Open
MateoLostanlen wants to merge 6 commits intomainfrom
Open
feat(alerts): unmatch a sequence from an alert#582MateoLostanlen wants to merge 6 commits intomainfrom
MateoLostanlen wants to merge 6 commits intomainfrom
Conversation
Move the alert recomputation helper out of the sequences endpoint module so other endpoints can reuse it.
POST /alerts/{alert_id}/sequences/{sequence_id}/unmatch detaches a sequence from an alert and recomputes the alert state. If the sequence is no longer linked to any alert, a new alert is created for it. Restricted to admin and agent scopes; rejects unmatch when the alert has a single sequence.
Cover the new alert/sequence unmatch flow: new alert creation when the sequence becomes orphaned, no-op when the sequence is still linked elsewhere, single-sequence rejection, missing link, role and cross-org access denial.
Scope rejection from get_jwt returns 403, not 401. The label_sequence unit test now patches refresh_alert_state at its imported location.
Defensive guard so an authorized agent cannot trigger creation of an alert in another organization through a cross-org sequence link. Use the alert's organization_id when creating the replacement alert.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #582 +/- ##
==========================================
- Coverage 88.75% 87.98% -0.77%
==========================================
Files 52 53 +1
Lines 2196 2239 +43
==========================================
+ Hits 1949 1970 +21
- Misses 247 269 +22
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:
|
Wrap the new POST /alerts/{alert_id}/sequences/{sequence_id}/unmatch route.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POST /alerts/{alert_id}/sequences/{sequence_id}/unmatch(admin + agent) that detaches a sequence from an alert and recomputes the alert state; if the sequence becomes orphaned a new alert is created for it. Reject when the alert has a single sequence.refresh_alert_statefromendpoints/sequences.pyintoservices/alerts.pyso both endpoints share the helper.