Skip to content

ref(grouping): Consolidate main exception id override logic #97541

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

Merged
merged 3 commits into from
Aug 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/sentry/grouping/strategies/newstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,9 @@ def chained_exception(
# exceptions. Either way, we need to wrap our exception components in a chained exception component.
exception_components_by_variant: dict[str, list[ExceptionGroupingComponent]] = {}

# Check for cases in which we want to switch the `main_exception_id` in order to use a different
# Handle cases in which we want to switch the `main_exception_id` in order to use a different
# exception than normal for the event title
main_exception_id = determine_main_exception_id(exceptions)
if main_exception_id:
event.data["main_exception_id"] = main_exception_id
_maybe_override_main_exception_id(event, exceptions)

for exception in exceptions:
for variant_name, component in exception_components_by_exception[id(exception)].items():
Expand Down Expand Up @@ -900,11 +898,12 @@ def react_error_with_cause(exceptions: list[SingleException]) -> int | None:
]


def determine_main_exception_id(exceptions: list[SingleException]) -> int | None:
def _maybe_override_main_exception_id(event: Event, exceptions: list[SingleException]) -> None:
main_exception_id = None
for func in MAIN_EXCEPTION_ID_FUNCS:
main_exception_id = func(exceptions)
if main_exception_id is not None:
break

return main_exception_id
if main_exception_id:
event.data["main_exception_id"] = main_exception_id
Loading