-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(aci): handle fake incident ids in IGOP lookup #103937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| # try looking up GroupOpenPeriod directly using calculated open_period_id | ||
| fake_id = incident_identifier or incident_id | ||
| if fake_id: | ||
| calculated_open_period_id = get_object_id_from_fake_id(int(fake_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Real incident IDs incorrectly treated as fake IDs
The fallback logic applies get_object_id_from_fake_id() to both incident_id and incident_identifier, but incident_id represents a real database ID from the IncidentGroupOpenPeriod table, not a fake ID. Subtracting 10^9 from a real incident ID produces a negative or incorrect value, preventing legitimate lookups when a real incident_id has no matching IGOP row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're sending workflow engine notifications for everyone now, all incidents are either real and fetched via IGOP table, or faked using the fake ID formula.
src/sentry/workflow_engine/endpoints/organization_incident_groupopenperiod_index.py
Outdated
Show resolved
Hide resolved
src/sentry/workflow_engine/endpoints/organization_incident_groupopenperiod_index.py
Outdated
Show resolved
Hide resolved
src/sentry/workflow_engine/endpoints/organization_incident_groupopenperiod_index.py
Show resolved
Hide resolved
src/sentry/workflow_engine/endpoints/serializers/incident_groupopenperiod_serializer.py
Outdated
Show resolved
Hide resolved
tests/sentry/workflow_engine/endpoints/test_organization_incident_groupopenperiod.py
Outdated
Show resolved
Hide resolved
mifu67
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math looks good! Idk about the cursor comments ¯_(ツ)_/¯ and let's merge the backend changes first.
src/sentry/workflow_engine/endpoints/organization_incident_groupopenperiod_index.py
Outdated
Show resolved
Hide resolved
src/sentry/workflow_engine/endpoints/organization_incident_groupopenperiod_index.py
Outdated
Show resolved
Hide resolved
| gop_queryset = gop_queryset.filter(group_id=group_id) | ||
|
|
||
| if open_period_id: | ||
| gop_queryset = gop_queryset.filter(id=open_period_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Conflicting ID filters in fallback query
The fallback logic filters GroupOpenPeriod by id=calculated_open_period_id on line 92, then filters by id=open_period_id on line 100 if provided. Since a row can't have two different IDs, this makes the query impossible to satisfy when open_period_id differs from calculated_open_period_id. The filter on line 100 either contradicts the earlier filter or is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignoring, in theory you shouldn't be passing incident and GOP ids together anyways
…#103938) Should probably be merged before #103937. If an open period comes in without a corresponding entry in the IGOP table, create a fake ID for the incident and pass it to the frontend, where it will be used for redirect logic. Do the same for detector IDs that don't have entries in the AlertRuleDetector table.
When looking up a GroupOpenPeriod via incident id, it's possible that there is no corresponding row in the IncidentGroupOpenPeriod table. We then assume that the incident id that was passed is a fake id, so we can use
get_object_id_from_fake_id()to get the open period id and group.