Title: If Exception.__context__ is an ExceptionGroup, Sentry doesn't capture the ExceptionGroup's children · Issue #3913 · getsentry/sentry-python · GitHub
Open Graph Title: If Exception.__context__ is an ExceptionGroup, Sentry doesn't capture the ExceptionGroup's children · Issue #3913 · getsentry/sentry-python
X Title: If Exception.__context__ is an ExceptionGroup, Sentry doesn't capture the ExceptionGroup's children · Issue #3913 · getsentry/sentry-python
Description: 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: try: try: raise ExceptionGroup("group", [ValueError("child1"), ValueError("child2")]) finally: raise Typ...
Open Graph Description: 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: try: try: raise ExceptionGroup("group", [ValueError("child1"), V...
X Description: 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: try: try: raise ExceptionGroup("group", [ValueErro...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/3913
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"If Exception.__context__ is an ExceptionGroup, Sentry doesn't capture the ExceptionGroup's children","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n1.29.2\n\n### Steps to Reproduce\n\nHere's a toy example that demonstrates the problem:\n```python\ntry:\n try:\n raise ExceptionGroup(\"group\", [ValueError(\"child1\"), ValueError(\"child2\")])\n finally:\n raise TypeError(\"bar\")\nexcept BaseException:\n sentry_sdk.capture_exception()\n```\n\n`sentry_sdk.capture_exception()` receives the `TypeError`. `TypeError.__context__` points to the `ExceptionGroup`; and then `ExceptionGroup.exceptions` points to `[ValueError(\"child1\"), ValueError(\"child2\")]`.\n\n### Expected Result\n\nThe Sentry event should contain all four exceptions: the `TypeError`, the `ExceptionGroup`, and the sub-exceptions `ValueError(\"child1\")` and `ValueError(\"child2\")`.\n\nAdditionally, the event should record that the `ExceptionGroup` is `TypeError.__context__` as opposed to `TypeError.__cause__`.\n\nNote 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()`:\n\n\u003cimg width=\"745\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/1c4bfbff-e300-408f-8b7c-9c82a7d3a192\" />\n\n\n### Actual Result\n\nWhen 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`:\n\n\u003cimg width=\"745\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/e5fb6d10-7b2b-4a59-9a9e-d9c173d2b06a\" />\n\nAlso, the \"Related Exceptions\" tree in the above screenshot appears to be nonsensical.\n\nI tested this with SDK version 1.29.2, but the bug appears to still be present in the latest version of the code.","author":{"url":"https://github.com/tmaxwell-anthropic","@type":"Person","name":"tmaxwell-anthropic"},"datePublished":"2025-01-10T04:57:21Z","url":"https://github.com/getsentry/sentry-python/issues/3913"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0fc4f56e-e103-b84e-ebb7-9887f10f327b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF46:3897F3:223827:2D4B5F:6B00C00A |
| html-safe-nonce | 55213d08ab203c4bb671cb05ee8ef5f4538f7633b5141ac5e9506c53c799afcd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjQ2OjM4OTdGMzoyMjM4Mjc6MkQ0QjVGOjZCMDBDMDBBIiwidmlzaXRvcl9pZCI6IjEyMzg0NjAyMTI1MDgxNDc3MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c3d2561e133a6e8936a82d5b66c4bac4cfd3148be30ebe90e0f2a8c12f7bb213 |
| hovercard-subject-tag | issue:2779285738 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/3913/issue_layout |
| twitter:image | https://opengraph.githubassets.com/39dc4217e3c87231d127aeb79437060f5c43ab890a4a0d83bb6967b78118241c/getsentry/sentry-python/issues/3913 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/39dc4217e3c87231d127aeb79437060f5c43ab890a4a0d83bb6967b78118241c/getsentry/sentry-python/issues/3913 |
| og:image:alt | 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: try: try: raise ExceptionGroup("group", [ValueError("child1"), V... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tmaxwell-anthropic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width