Skip to content

Conversation

@ameliahsu
Copy link
Member

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.

@ameliahsu ameliahsu requested a review from mifu67 November 24, 2025 22:58
@ameliahsu ameliahsu requested a review from a team as a code owner November 24, 2025 22:58
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 24, 2025
# 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))
Copy link
Contributor

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.

Fix in Cursor Fix in Web

Copy link
Contributor

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.

Copy link
Contributor

@mifu67 mifu67 left a 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.

gop_queryset = gop_queryset.filter(group_id=group_id)

if open_period_id:
gop_queryset = gop_queryset.filter(id=open_period_id)
Copy link
Contributor

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.

Fix in Cursor Fix in Web

Copy link
Member Author

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

mifu67 added a commit that referenced this pull request Nov 25, 2025
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants