diff --git a/src/sentry/grouping/strategies/newstyle.py b/src/sentry/grouping/strategies/newstyle.py index 84b7e16169ab05..6b0e250413c5ed 100644 --- a/src/sentry/grouping/strategies/newstyle.py +++ b/src/sentry/grouping/strategies/newstyle.py @@ -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(): @@ -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