Skip to content

chore(alerts): Remove unused incidents code#115236

Draft
ceorourke wants to merge 1 commit intomasterfrom
ceorourke/more-unused-code-removal
Draft

chore(alerts): Remove unused incidents code#115236
ceorourke wants to merge 1 commit intomasterfrom
ceorourke/more-unused-code-removal

Conversation

@ceorourke
Copy link
Copy Markdown
Member

Delete a whole lot of unused incidents code.

@ceorourke ceorourke requested a review from a team as a code owner May 8, 2026 22:04
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 8, 2026
Comment on lines 108 to 114
kwargs["incident"] = gop
return args, kwargs

# Legacy path (flag off): replicate IncidentEndpoint.convert_args lookup.
# PUT: update_incident_status operates on the legacy Incident model.
try:
incident = kwargs["incident"] = Incident.objects.get(
organization=organization, identifier=int_id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Removing the legacy fallback for GET requests makes legacy incidents (those without a GroupOpenPeriod record) inaccessible, while PUT requests still use the legacy Incident model.
Severity: HIGH

Suggested Fix

The legacy fallback logic for GET requests should be restored until the data migration is complete and the PUT endpoint is also migrated to use the new workflow engine models. This prevents legacy incidents from becoming inaccessible.

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#L108-L114

Potential issue: The removal of the legacy fallback logic for `GET` requests in
`organization_incident_details.py` causes a regression. Legacy incidents, which exist in
the `Incident` table but lack a corresponding `GroupOpenPeriod` record, will now return
a 404 error on `GET` requests. This happens because the `GET` path now exclusively
queries for `GroupOpenPeriod` and raises `ResourceDoesNotExist` if not found. However,
the `PUT` path for the same endpoint still operates on the legacy `Incident` model,
creating an inconsistency where an incident can be updated but not viewed. Similarly,
the incident index endpoint will no longer list these legacy incidents.

Also affects:

  • src/sentry/incidents/endpoints/organization_incident_index.py

Did we get this right? 👍 / 👎 to inform future reviews.

@ceorourke ceorourke marked this pull request as draft May 8, 2026 22:42
@ceorourke ceorourke force-pushed the ceorourke/more-unused-code-removal branch from 34dd5bc to 0c171df Compare May 8, 2026 23:37
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Backend Test Failures

Failures on 904bd18 in this run:

tests/snuba/api/endpoints/test_organization_events_stats_mep.py::OrganizationEventsStatsMetricsEnhancedPerformanceEndpointTest::test_metrics_enhanced_defaults_to_transactions_with_feature_flaglog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/api/endpoints/test_organization_events_stats_mep.py:1071: in test_metrics_enhanced_defaults_to_transactions_with_feature_flag
    assert response.data["data"][0][1][0]["count"] == 1
E   assert 0 == 1
tests/snuba/tagstore/test_tagstore_backend.py::TagStorageTest::test_get_group_tag_value_count_genericlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/tagstore/test_tagstore_backend.py:410: in test_get_group_tag_value_count_generic
    assert (
E   AssertionError: assert 0 == 1
E    +  where 0 = <bound method SnubaTagStorage.get_group_tag_value_count of <sentry.tagstore.snuba.backend.SnubaTagStorage object at 0x7ff8e8362d00>>(<Group at 0x7ff8f2f7b890: id=242, project_id=4558105028919328>, 165, 'foo', {'organization_id': 1234, 'referrer': 'tagstore.get_group_tag_value_count'})
E    +    where <bound method SnubaTagStorage.get_group_tag_value_count of <sentry.tagstore.snuba.backend.SnubaTagStorage object at 0x7ff8e8362d00>> = <sentry.tagstore.snuba.backend.SnubaTagStorage object at 0x7ff8e8362d00>.get_group_tag_value_count
E    +      where <sentry.tagstore.snuba.backend.SnubaTagStorage object at 0x7ff8e8362d00> = <tests.snuba.tagstore.test_tagstore_backend.TagStorageTest testMethod=test_get_group_tag_value_count_generic>.ts
E    +    and   165 = <Environment at 0x7ff8e83d3b50: id=165, organization_id=4558105028853792, name='test'>.id
tests/snuba/tagstore/test_tagstore_backend.py::TagStorageTest::test_get_group_tag_key_genericlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/tagstore/test_tagstore_backend.py:580: in test_get_group_tag_key_generic
    assert set(keys) == {"biz", "environment", "foo", "sentry:user", "level", "sentry:release"}
E   AssertionError: assert set() == {'biz', 'envi...'sentry:user'}
E     
E     Extra items in the right set:
E     'level'
E     'environment'
E     'sentry:user'
E     'foo'
E     'sentry:release'
E     'biz'
E     
E     Full diff:
E     + set()
E     - {
E     -     'biz',
E     -     'environment',
E     -     'foo',
E     -     'level',
E     -     'sentry:release',
E     -     'sentry:user',
E     - }

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.

1 participant