René's URL Explorer Experiment


Title: Sentry removes chained exceptions during ASGI application crash · Issue #5624 · getsentry/sentry-python · GitHub

Open Graph Title: Sentry removes chained exceptions during ASGI application crash · Issue #5624 · getsentry/sentry-python

X Title: Sentry removes chained exceptions during ASGI application crash · Issue #5624 · getsentry/sentry-python

Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce We have an ASGI application; we use Sentry in it, by way of calling sentry_sdk.init. We recently had a incident; during that incident, the ASGI application ...

Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce We have an ASGI application; we use Sentry in it, by way of calling sentry_sdk.init. We recently had a incident; dur...

X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce We have an ASGI application; we use Sentry in it, by way of calling sentry_sdk.init. We recently had a incident; dur...

Opengraph URL: https://github.com/getsentry/sentry-python/issues/5624

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sentry removes chained exceptions during ASGI application crash","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n2.35.0\n\n### Steps to Reproduce\n\nWe have an ASGI application; we use Sentry in it, by way of calling `sentry_sdk.init`.\n\nWe recently had a incident; during that incident, the ASGI application was crashing. Our logs contained:\n```\n2026-03-03 16:59:59,994 - uvicorn.error - ERROR - Exception in ASGI application\nTraceback (most recent call last):\n  File \"/…/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py\", line 366, in run_asgi\n    result = await app(self.scope, self.receive, self.send)\n[snipped]\n  File \"/…/.venv/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py\", line 408, in _sentry_patched_asgi_app\n    return await middleware(scope, receive, send)\n  File \"/…/.venv/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py\", line 179, in _run_asgi3\n    return await self._run_app(scope, receive, send, asgi_version=3)\n  File \"/…/.venv/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py\", line 268, in _run_app\n    raise exc from None\n  File \"/…/.venv/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py\", line 263, in _run_app\n    return await self.app(\n  File \"/…/.venv/lib/python3.10/site-packages/starlette/applications.py\", line 113, in __call__\n    await self.middleware_stack(scope, receive, send)\n  File \"/…/.venv/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py\", line 150, in _create_span_call\n    return await old_call(app, scope, receive, send, **kwargs)\n[snip more frames]\n  File \"/…/app/middleware/authorization_middleware.py\", line 79, in __call__\n    verifier.verify(token, request)\n  File \"/…/app/token_verifier.py\", line 72, in verify\n    raise HTTPException(\nstarlette.exceptions.HTTPException: 401: Failed to Authorize\"\n```\n\nNow, that exception is a bug; I think we're supposed to return a 401 _response_, not raise.\n\nBut what hampered us during this incident is that line 72 there is:\n```\n        except Exception as e:\n            raise HTTPException(\n                status_code=status.HTTP_401_UNAUTHORIZED,\n                detail=\"Failed to Authorize\",\n                headers={\"WWW-Authenticate\": \"Bearer\"},\n            ) from e\n```\n\n(Note that this is still our code.) Note the `from e`: there should be an additional exception's worth of stack frames, but the stack trace above terminated there. That is, `from e` should normally look something like this:\n\n```\nTraceback (most recent call last):\n[snip]\nRuntimeError: I couldn't do it.\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n[snip]\n    raise RuntimeError(\"ouch\") from e\nRuntimeError: ouch\n```\n\nHaving the first bit (this exception led to the second exception) _would have really helped us in the incident._\n\nBy default, FastAPI / Uvicorn will emit that \"The above exception was …\" bit automatically. In fact, I copy/pasted that snippet from a test FastAPI app. So, in a small test, it works; in our production code, not so much.\n\nThis frame in Sentry's code, I think, is why we do _not_, in prod, get chained exceptions in the backtrace:\n```\n  File \"/…/.venv/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py\", line 268, in _run_app\n    raise exc from None\n```\n\nThat code is [here](https://github.com/getsentry/sentry-python/blob/2.35.0/sentry_sdk/integrations/asgi.py#L268).\n\nThat `from None` removes the context/exception cause from the exception. There does not seem to be a reason for that in the linked code; this means we lose the context from the exception in our logs.\n\nThere is also [this line](https://github.com/getsentry/sentry-python/blob/2.35.0/sentry_sdk/integrations/asgi.py#L194), and I think both `from None`s are incorrect.\n\n**Sentry should re-propagate the current exception with whatever `__context__`/`__cause__` is has.** A simple `raise` (without \"`exc`\") is sufficient.\n\nSee [Exception Chaining](https://docs.python.org/3/tutorial/errors.html#exception-chaining) in the Python docs for more information.\n\n### Expected Result\n\nSentry does not de-chain exceptions during an ASGI crash\n\n### Actual Result\n\nSentry de-chains the exception, resulting in our logging library not logging a full stack trace.","author":{"url":"https://github.com/roy-work","@type":"Person","name":"roy-work"},"datePublished":"2026-03-10T01:24:26Z","url":"https://github.com/getsentry/sentry-python/issues/5624"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2ff0e7e8-5fb9-18f9-a20e-a289e70af575
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCAC:842EC:7E7B24:AAB1B7:6B00E06A
html-safe-nonce0bc32717c22bd42c7ba20bf7a9bdfbb546cb5a11de886154020eebc1fb88722f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0FDOjg0MkVDOjdFN0IyNDpBQUIxQjc6NkIwMEUwNkEiLCJ2aXNpdG9yX2lkIjoiNjc0MzAxMTE5MzgwMTIwMzgxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3b332b46201764166d965773db3154ff1a910c5fbfc2935b7a80d8a871217cb4
hovercard-subject-tagissue:4048796195
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/5624/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a1cf8ea0341d8a13293ecd9990047796316ec0ca12e33e1723161b3e67d95510/getsentry/sentry-python/issues/5624
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a1cf8ea0341d8a13293ecd9990047796316ec0ca12e33e1723161b3e67d95510/getsentry/sentry-python/issues/5624
og:image:altHow do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce We have an ASGI application; we use Sentry in it, by way of calling sentry_sdk.init. We recently had a incident; dur...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameroy-work
hostnamegithub.com
expected-hostnamegithub.com
None043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id137814779
octolytics-dimension-repository_nwogetsentry/sentry-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id137814779
octolytics-dimension-repository_network_root_nwogetsentry/sentry-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5425dc24e8bd8d6fca9641a12afc984825a43875
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/issues/5624#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F5624
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F5624
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-python
Reloadhttps://github.com/getsentry/sentry-python/issues/5624
Reloadhttps://github.com/getsentry/sentry-python/issues/5624
Reloadhttps://github.com/getsentry/sentry-python/issues/5624
getsentryhttps://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Codehttps://github.com/getsentry/sentry-python
Issues345 (345)https://github.com/getsentry/sentry-python/issues
Pull requests42 (42)https://github.com/getsentry/sentry-python/pulls
Discussionshttps://github.com/getsentry/sentry-python/discussions
Actionshttps://github.com/getsentry/sentry-python/actions
Security and quality2 (2)https://github.com/getsentry/sentry-python/security
Insightshttps://github.com/getsentry/sentry-python/insights
https://github.com/getsentry/sentry-python
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/5624
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/5624
Sentry removes chained exceptions during ASGI application crashhttps://github.com/getsentry/sentry-python/issues/5624#top
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
Integration: ASGIhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20ASGI%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
https://github.com/roy-work
roy-workhttps://github.com/roy-work
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#issue-4048796195
herehttps://github.com/getsentry/sentry-python/blob/2.35.0/sentry_sdk/integrations/asgi.py#L268
this linehttps://github.com/getsentry/sentry-python/blob/2.35.0/sentry_sdk/integrations/asgi.py#L194
Exception Chaininghttps://docs.python.org/3/tutorial/errors.html#exception-chaining
roy-workhttps://github.com/roy-work
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23415343965
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23415345627
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23415346676
https://github.com/apps/linear-code
linear-codehttps://github.com/apps/linear-code
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4027976343
Linear Codehttps://linear.app
PY-2128https://linear.app/getsentry/issue/PY-2128/sentry-removes-chained-exceptions-during-asgi-application-crash
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4029344103
@roy-workhttps://github.com/roy-work
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23422217726
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624
sentrivanahttps://github.com/sentrivana
Integration: ASGIhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20ASGI%22
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23425649046
roy-workhttps://github.com/roy-work
on Mar 10, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23446515628
Just re-raise the original exception, as-ishttps://github.com/getathelas/sentry-python/commit/dd3de3679c83847082ddfbf4ae200202a5ee1d49
https://docs.github.com/articles/closing-issues-via-commit-messages
dd3de36https://github.com/getathelas/sentry-python/commit/dd3de3679c83847082ddfbf4ae200202a5ee1d49
https://github.com/alexander-alderman-webb
alexander-alderman-webbhttps://github.com/alexander-alderman-webb
on Mar 19, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4090001685
@roy-workhttps://github.com/roy-work
#5709https://github.com/getsentry/sentry-python/pull/5709
alexander-alderman-webbhttps://github.com/alexander-alderman-webb
on Mar 19, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23718024997
fix: Do not raise from None (#5709)https://github.com/getsentry/sentry-python/commit/2e024fbbf22ebc786f7299277a52a5d49d129a72
#5709https://github.com/getsentry/sentry-python/pull/5709
2e024fbhttps://github.com/getsentry/sentry-python/commit/2e024fbbf22ebc786f7299277a52a5d49d129a72
https://github.com/roy-work
roy-workhttps://github.com/roy-work
on Mar 19, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4091577708
spacebar heaterhttps://xkcd.com/1172/
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Mar 19, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23724918052
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Mar 19, 2026https://github.com/getsentry/sentry-python/issues/5624
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Mar 20, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4096150580
spacebar heaterhttps://xkcd.com/1172/
since abandonedhttps://github.com/getsentry/sentry-python/discussions/4955
3.0 branchhttps://github.com/getsentry/sentry-python/pull/5005
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Mar 20, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23743659629
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Mar 20, 2026https://github.com/getsentry/sentry-python/issues/5624
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Mar 20, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4096707027
add an experimental optionhttps://github.com/getsentry/sentry-python/pull/5714
sentrivanahttps://github.com/sentrivana
completedhttps://github.com/getsentry/sentry-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Mar 20, 2026https://github.com/getsentry/sentry-python/issues/5624#event-23745958704
https://github.com/roy-work
roy-workhttps://github.com/roy-work
on Mar 23, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4113415231
add an experimental optionhttps://github.com/getsentry/sentry-python/pull/5714
https://github.com/sentrivana
sentrivanahttps://github.com/sentrivana
on Mar 24, 2026https://github.com/getsentry/sentry-python/issues/5624#issuecomment-4115994214
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-python/issues/5624
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/5624
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
Integration: ASGIhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20ASGI%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.