Skip to content

feat(workflow): Make OrganizationIncidentDetailsEndpoint.get support single-written workflows#111588

Merged
kcons merged 3 commits intomasterfrom
kcons/incdetails
Mar 26, 2026
Merged

feat(workflow): Make OrganizationIncidentDetailsEndpoint.get support single-written workflows#111588
kcons merged 3 commits intomasterfrom
kcons/incdetails

Conversation

@kcons
Copy link
Member

@kcons kcons commented Mar 25, 2026

Part of the project described in src/sentry/workflow_engine/docs/legacy_backport.md.

Fixes ISWF-2296.

@kcons kcons requested a review from a team as a code owner March 25, 2026 23:04
@linear-code
Copy link

linear-code bot commented Mar 25, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 25, 2026
Copy link
Member

@ceorourke ceorourke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, the bot complaining about put requests is fine for now

Comment on lines +81 to +90
try:
igop = IncidentGroupOpenPeriod.objects.select_related(
"group_open_period__project",
"group_open_period__group",
).get(
incident_identifier=int_id,
group_open_period__project__organization=organization,
)
gop = igop.group_open_period
except IncidentGroupOpenPeriod.DoesNotExist:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: A query using a fake ID will cause an integer overflow because the incident_identifier field is a 32-bit IntegerField but the ID can exceed 10^10, leading to a DataError.
Severity: HIGH

Suggested Fix

Change the type of the incident_identifier field in the IncidentGroupOpenPeriod model from models.IntegerField to models.BigIntegerField. This will ensure the field can accommodate the large numerical values of the fake IDs without causing a database overflow error.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/incidents/endpoints/organization_incident_details.py#L81-L90

Potential issue: The code generates a "fake ID" for an `IncidentGroupOpenPeriod` by
adding an offset of 10^10 to a `GroupOpenPeriod` object's ID. This large number is then
used to query the `incident_identifier` field in the database. However, the
`incident_identifier` field is defined as a 32-bit `IntegerField`, which has a maximum
value of approximately 2.1 billion. Since the fake ID will always be at least 10
billion, it exceeds the capacity of the field. This mismatch causes the database to
raise a `DataError` for an "integer out of range". The existing error handling does not
catch this specific exception, leading to an unhandled error and a 500 Internal Server
Error response.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a passing test that hits this case, so I'm pretty sure postgres doesn't overflow when simply doing an comparison. Valid point, though: fake ids probably should be checked first as a matter of idiom.

@kcons kcons merged commit a31ee4b into master Mar 26, 2026
64 checks passed
@kcons kcons deleted the kcons/incdetails branch March 26, 2026 00:02
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.

2 participants