Skip to content

fix: Just re-raise the original exception, as-is#5632

Open
roy-work wants to merge 1 commit intogetsentry:masterfrom
getathelas:roy/fix-reraise
Open

fix: Just re-raise the original exception, as-is#5632
roy-work wants to merge 1 commit intogetsentry:masterfrom
getathelas:roy/fix-reraise

Conversation

@roy-work
Copy link

Description

In Python raise … from None is an explicit request to raise the exception but to suppress any exception chaining. (See: https://docs.python.org/3/tutorial/errors.html#exception-chaining)

This means that if, when an ASGI exception crashes, an exception causes another exception, that when the second exception (which has the first chained to it) reaches this point in the stack, these lines will re-raise it, but remove the chained exception. This can be confusing: ASGI frameworks will normally log a stack trace of the crashing application, but that stack trace will now be truncated, due to this from None removing the chained exception.

The chained exception (which is the exception that kicked off the entire stack unwind) is usually the more interesting one, when you're debugging.

Neither of the two changed lines seem to have a reason for … from None. Additionally, since they just re-raise the original exception, simply "raise" suffices.

Issues

Reminders

In Python `raise … from None` is an explicit request to raise the
exception but to suppress any exception chaining. (See:
https://docs.python.org/3/tutorial/errors.html#exception-chaining)

This means that if, when an ASGI exception crashes, an exception causes
another exception, that when the second exception (which has the first
chained to it) reaches this point in the stack, these lines will
re-raise it, but remove the chained exception. This can be confusing:
ASGI frameworks will normally log a stack trace of the crashing
application, but that stack trace will now be truncated, due to this
`from None` removing the chained exception.

The chained exception (which is the exception that kicked off the entire
stack unwind) is usually the more interesting one, when you're
debugging.

Neither of the two changed lines seem to have a reason for `… from
None`. Additionally, since they just re-raise the original exception,
simply "`raise`" suffices.

Fixes: getsentry#5624
@roy-work roy-work requested a review from a team as a code owner March 10, 2026 20:41
@github-actions
Copy link
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (crons) Add owner field to MonitorConfig by julwhitney13 in #5610
  • (pydantic-ai) Add tool description to execute_tool spans by ericapisani in #5596

Bug Fixes 🐛

  • (celery) Propagate user-set headers by sentrivana in #5581
  • (utils) Avoid double serialization of strings in safe_serialize by ericapisani in #5587
  • Just re-raise the original exception, as-is by roy-work in #5632

Documentation 📚

  • (openai-agents) Remove inapplicable comment by alexander-alderman-webb in #5495
  • Add AGENTS.md by sentrivana in #5579
  • Add set_attribute example to changelog by sentrivana in #5578

Internal Changes 🔧

Openai Agents

  • Do not fail on new tool fields by alexander-alderman-webb in #5625
  • Stop expecting a specific function name by alexander-alderman-webb in #5623
  • Set streaming header when library uses with_streaming_response() by alexander-alderman-webb in #5583
  • Replace mocks with httpx for streamed responses by alexander-alderman-webb in #5580
  • Replace mocks with httpx in non-MCP tool tests by alexander-alderman-webb in #5602
  • Replace mocks with httpx in MCP tool tests by alexander-alderman-webb in #5605
  • Replace mocks with httpx in handoff tests by alexander-alderman-webb in #5604
  • Replace mocks with httpx in API error test by alexander-alderman-webb in #5601
  • Replace mocks with httpx in non-error single-response tests by alexander-alderman-webb in #5600
  • Remove test for unreachable state by alexander-alderman-webb in #5584
  • Expect namespace tool field for new openai versions by alexander-alderman-webb in #5599

Other

  • (httpx) Resolve type checking failures by alexander-alderman-webb in #5626
  • (pyramid) Support alpha suffixes in version parsing by alexander-alderman-webb in #5618
  • Normalize dots in package names in populate_tox.py by alexander-alderman-webb in #5574
  • Do not run actions on potel-base by sentrivana in #5614

🤖 This preview updates automatically when you update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentry removes chained exceptions during ASGI application crash

1 participant