You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sentry_sdk.capture_exception() receives the TypeError. TypeError.__context__ points to the ExceptionGroup; and then ExceptionGroup.exceptions points to [ValueError("child1"), ValueError("child2")].
Expected Result
The Sentry event should contain all four exceptions: the TypeError, the ExceptionGroup, and the sub-exceptions ValueError("child1") and ValueError("child2").
Additionally, the event should record that the ExceptionGroup is TypeError.__context__ as opposed to TypeError.__cause__.
Note that the sentry_sdk.utils.exceptions_from_error() function actually does this correctly, but it isn't getting invoked in this case. Here's a screenshot of how it looks if I patch the Sentry SDK to always use sentry_sdk.utils.exceptions_from_error():
Actual Result
When the TypeError is passed into sentry_sdk.utils.exceptions_from_error_tuple(), it checks whether the TypeError is an ExceptionGroup or not: https://github.com/getsentry/sentry-python/blob/2.19.2/sentry_sdk/utils.py#L968-L1009 Because the TypeError is not an ExceptionGroup, it calls walk_exception_chain(), which examines TypeError.__context__ to find the ExceptionGroup; but it doesn't recurse into the sub-exceptions ValueError("child1") and ValueError("child2"). So the Sentry event only contains the TypeError and the ExceptionGroup:
Also, the "Related Exceptions" tree in the above screenshot appears to be nonsensical.
I tested this with SDK version 1.29.2, but the bug appears to still be present in the latest version of the code.
The text was updated successfully, but these errors were encountered:
(Minor related issue: I noticed that sentry_sdk.utils.exceptions_from_error() doesn't pass parent_id when recursing here and here. That seems like it might have been a bug?)
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.29.2
Steps to Reproduce
Here's a toy example that demonstrates the problem:
sentry_sdk.capture_exception()
receives theTypeError
.TypeError.__context__
points to theExceptionGroup
; and thenExceptionGroup.exceptions
points to[ValueError("child1"), ValueError("child2")]
.Expected Result
The Sentry event should contain all four exceptions: the
TypeError
, theExceptionGroup
, and the sub-exceptionsValueError("child1")
andValueError("child2")
.Additionally, the event should record that the
ExceptionGroup
isTypeError.__context__
as opposed toTypeError.__cause__
.Note that the
sentry_sdk.utils.exceptions_from_error()
function actually does this correctly, but it isn't getting invoked in this case. Here's a screenshot of how it looks if I patch the Sentry SDK to always usesentry_sdk.utils.exceptions_from_error()
:Actual Result
When the
TypeError
is passed intosentry_sdk.utils.exceptions_from_error_tuple()
, it checks whether theTypeError
is anExceptionGroup
or not: https://github.com/getsentry/sentry-python/blob/2.19.2/sentry_sdk/utils.py#L968-L1009 Because theTypeError
is not anExceptionGroup
, it callswalk_exception_chain()
, which examinesTypeError.__context__
to find theExceptionGroup
; but it doesn't recurse into the sub-exceptionsValueError("child1")
andValueError("child2")
. So the Sentry event only contains theTypeError
and theExceptionGroup
:Also, the "Related Exceptions" tree in the above screenshot appears to be nonsensical.
I tested this with SDK version 1.29.2, but the bug appears to still be present in the latest version of the code.
The text was updated successfully, but these errors were encountered: