Skip to content

fix(grouping): Avoid mutating class-level initial_context in grouping info endpoint#109011

Closed
joshuarli wants to merge 1 commit intomasterfrom
fix/test-pollution-grouping-info-108923
Closed

fix(grouping): Avoid mutating class-level initial_context in grouping info endpoint#109011
joshuarli wants to merge 1 commit intomasterfrom
fix/test-pollution-grouping-info-108923

Conversation

@joshuarli
Copy link
Member

Summary

Fixes #108923

Same root cause as #109009. EventGroupingInfoEndpoint.get() mutates the class-level initial_context dict on StrategyConfiguration, causing reverse_stacktraces to persist and reverse frame order in subsequent grouping info snapshot tests.

  • Create an instance-level copy of initial_context before mutating it

Test plan

  • Verified pytest tests/sentry/issues/endpoints/test_event_grouping_info.py::EventGroupingInfoEndpointTestCase::test_error_event_exception_order tests/sentry/grouping/test_grouping_info.py::test_grouping_info[newstyle:2026_01_20-javascript_xbrowser_edge] passes

…uping info endpoint

The EventGroupingInfoEndpoint was mutating the class-level `initial_context`
dict on StrategyConfiguration when setting `reverse_stacktraces`. Since
`initial_context` is a class attribute (not instance), this mutation persisted
across all subsequent uses of the same grouping config class, causing
`reverse_when_serializing` to be set on stacktrace components and reversing
frame order in grouping info snapshots.

Fix: create an instance-level copy of `initial_context` before mutating it.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 23, 2026
@joshuarli
Copy link
Member Author

Closing as duplicate of #109009 which references all 9 issues.

@joshuarli joshuarli closed this Feb 23, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components test-pollution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test pollution: tests/sentry/grouping/test_grouping_info.py::test_grouping_info[newstyle:2026_01_20-javascript_xbrowser_edge]

1 participant