Title: Handle control flow exceptions when assigning span status · Issue #6408 · getsentry/sentry-python · GitHub
Open Graph Title: Handle control flow exceptions when assigning span status · Issue #6408 · getsentry/sentry-python
X Title: Handle control flow exceptions when assigning span status · Issue #6408 · getsentry/sentry-python
Description: We have a few cases of libraries using custom exception types as control flow signals, e.g.: HueyControlFlowExceptions LangGraph's GraphInterrupt and GraphBubbleUp: #6384 The should_be_treated_as_error() function is currently used to det...
Open Graph Description: We have a few cases of libraries using custom exception types as control flow signals, e.g.: HueyControlFlowExceptions LangGraph's GraphInterrupt and GraphBubbleUp: #6384 The should_be_treated_as_e...
X Description: We have a few cases of libraries using custom exception types as control flow signals, e.g.: HueyControlFlowExceptions LangGraph's GraphInterrupt and GraphBubbleUp: #6384 The should_be_treated_...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/6408
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle control flow exceptions when assigning span status","articleBody":"We have a few cases of libraries using custom exception types as control flow signals, e.g.:\n- `HueyControlFlowExceptions`\n- LangGraph's `GraphInterrupt` and `GraphBubbleUp`: https://github.com/getsentry/sentry-python/issues/6384\n\nThe [`should_be_treated_as_error()`](https://github.com/getsentry/sentry-python/blob/212e0cde3426ca9ea96ae737d74e0d972bbf1f18/sentry_sdk/utils.py#L1986) function is currently used to determine whether a transaction or span is assigned the `internal_error` or `error` status [in `Span.__exit__()`](https://github.com/getsentry/sentry-python/blob/212e0cde3426ca9ea96ae737d74e0d972bbf1f18/sentry_sdk/tracing.py#L398) and [in `StreamedSpan.__exit__()`](https://github.com/getsentry/sentry-python/blob/212e0cde3426ca9ea96ae737d74e0d972bbf1f18/sentry_sdk/traces.py#L335), respectively. As `should_be_treated_as_error()` currently holds an ever-expanding number of special cases, code is added that does not apply in the majority of cases (dead code if the relevant integrations did not create the span). \n\n**Proposal**\n\nAdd a parameter to `Span.__init__()`, `start_span()`, `start_transaction()` and `start_child()` (and equivalent span streaming APIs) that accepts a set or tuple of control flow exceptions. Special case against the exceptions in the set on `__exit__()`. The parameter can be called `control_flow_exceptions`.\n\nFor example, in the AIOHTTP integration, the parameter would be set to `control_flow_exceptions=(AIOHttpHttpException, )`.","author":{"url":"https://github.com/alexander-alderman-webb","@type":"Person","name":"alexander-alderman-webb"},"datePublished":"2026-05-26T09:20:08Z","url":"https://github.com/getsentry/sentry-python/issues/6408"}
| 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:277e4ca2-3f8f-3c1e-34b3-51d062b496c1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B778:26ECEB:343457:44D50B:6B00C391 |
| html-safe-nonce | d26188fd111383efbc99862b49c62c44c7c6add63d6750ed4afefd0f2947e508 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzc4OjI2RUNFQjozNDM0NTc6NDRENTBCOjZCMDBDMzkxIiwidmlzaXRvcl9pZCI6IjQwNjIxNzQ0MDk1ODUxMTYwNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ec964bb00d73b4085be3379bfd70b33f4a67a9e6c6250da549372ceb092a3502 |
| hovercard-subject-tag | issue:4523011382 |
| 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/6408/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30653ede80dec895644bdbdb8ab0d8bca94f41a13e0dfdddf292cd0dd9c0a03d/getsentry/sentry-python/issues/6408 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30653ede80dec895644bdbdb8ab0d8bca94f41a13e0dfdddf292cd0dd9c0a03d/getsentry/sentry-python/issues/6408 |
| og:image:alt | We have a few cases of libraries using custom exception types as control flow signals, e.g.: HueyControlFlowExceptions LangGraph's GraphInterrupt and GraphBubbleUp: #6384 The should_be_treated_as_e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexander-alderman-webb |
| 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