René's URL Explorer Experiment


Title: Django ASGI: send_default_pii triggers request.user.is_authenticated sync access · Issue #5274 · getsentry/sentry-python · GitHub

Open Graph Title: Django ASGI: send_default_pii triggers request.user.is_authenticated sync access · Issue #5274 · getsentry/sentry-python

X Title: Django ASGI: send_default_pii triggers request.user.is_authenticated sync access · Issue #5274 · getsentry/sentry-python

Description: Summary When running Django under ASGI with send_default_pii=True, Sentry’s Django integration calls request.user.is_authenticated in the ASGI event processor. On Django 5.x this triggers lazy session-backed user resolution in an async c...

Open Graph Description: Summary When running Django under ASGI with send_default_pii=True, Sentry’s Django integration calls request.user.is_authenticated in the ASGI event processor. On Django 5.x this triggers lazy sess...

X Description: Summary When running Django under ASGI with send_default_pii=True, Sentry’s Django integration calls request.user.is_authenticated in the ASGI event processor. On Django 5.x this triggers lazy sess...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Django ASGI: send_default_pii triggers request.user.is_authenticated sync access","articleBody":"### Summary\nWhen running Django under ASGI with `send_default_pii=True`, Sentry’s Django integration calls `request.user.is_authenticated` in the ASGI event processor. On Django 5.x this triggers lazy session-backed user resolution in an async context and raises `SynchronousOnlyOperation: You cannot call this from an async context`.\n\nThis appears to happen when the request uses Django’s session auth (e.g. Django admin). It does not occur when user objects are already concretely loaded (custom auth middleware). Disabling `send_default_pii` avoids the error.\n\n### Environment\n- Python: 3.11\n- Django: 5.1.2\n- sentry-sdk: 2.48.0\n- Deployment: ASGI (gunicorn + uvicorn worker)\n\n### Steps to Reproduce\n1. Configure Django with `AuthenticationMiddleware` + `SessionMiddleware`.\n2. Run under ASGI.\n3. Configure Sentry with `send_default_pii=True`.\n4. Hit `/admin/` (or any endpoint using Django session auth).\n\n### Actual Behavior\nSentry logs an internal SDK error:\n```\n.../django/utils/functional.py in _setup\n.../sentry_sdk/integrations/django/__init__.py in is_authenticated\nreturn request_user.is_authenticated\n.../sentry_sdk/integrations/django/__init__.py in _set_user_info\nif user is None or not is_authenticated(user):\n.../sentry_sdk/integrations/django/asgi.py in asgi_request_event_processor\n_set_user_info(request, event)\n.../django/contrib/sessions/backends/base.py in _get_session\nreturn self._session_cache\nSynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.\n```\n\n### Expected Behavior\nIn async contexts, the Django integration should avoid touching `request.user` synchronously. Ideally it should use async-safe APIs (e.g. `request.auser()` / `auth.aget_user`) or skip user capture in ASGI when `send_default_pii` is enabled.\n\n### Notes\n- This appears limited to async requests; WSGI does not raise.\n- A workaround is `send_default_pii=False` and manually calling `sentry_sdk.set_user()` after resolving the user asynchronously.\n","author":{"url":"https://github.com/ohnoah","@type":"Person","name":"ohnoah"},"datePublished":"2026-01-05T10:38:34Z","url":"https://github.com/getsentry/sentry-python/issues/5274"}

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:82d02ffb-6d5c-657d-5174-133433238e0d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8C4A:2ADD62:54B89F:71C7CB:6B00A787
html-safe-nonce3c8e8551adcc357a726c5ba38334fc65927dcb2780c3101aa6acb1f891611a6b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzRBOjJBREQ2Mjo1NEI4OUY6NzFDN0NCOjZCMDBBNzg3IiwidmlzaXRvcl9pZCI6IjUyNzIwOTQ2OTE0NjUxNDQxOTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1f770fdec14152042dbd5491ef2705d9cfedfd7512dcbffba0725d9681b2e298
hovercard-subject-tagissue:3781008141
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/5274/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7d15b16598203d476c05d568b00934162a8d9e3a8997359f772e99b89a0c18f4/getsentry/sentry-python/issues/5274
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7d15b16598203d476c05d568b00934162a8d9e3a8997359f772e99b89a0c18f4/getsentry/sentry-python/issues/5274
og:image:altSummary When running Django under ASGI with send_default_pii=True, Sentry’s Django integration calls request.user.is_authenticated in the ASGI event processor. On Django 5.x this triggers lazy sess...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameohnoah
hostnamegithub.com
expected-hostnamegithub.com
None455b493e3402a3a3a06beac5d20bb7db3da060808b220aa48d6a7eca7c59863a
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
release2f575159976167242d488c0b062eb355c4e198b7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/issues/5274#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F5274
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%2F5274
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/5274
Reloadhttps://github.com/getsentry/sentry-python/issues/5274
Reloadhttps://github.com/getsentry/sentry-python/issues/5274
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/5274
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/5274
Django ASGI: send_default_pii triggers request.user.is_authenticated sync accesshttps://github.com/getsentry/sentry-python/issues/5274#top
https://github.com/sl0thentr0py
Better Async Supporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Better%20Async%20Support%22
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
Integration: Djangohttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20Django%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
https://github.com/ohnoah
ohnoahhttps://github.com/ohnoah
on Jan 5, 2026https://github.com/getsentry/sentry-python/issues/5274#issue-3781008141
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 Jan 5, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21851236103
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Jan 5, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21851237788
https://github.com/apps/linear
linearhttps://github.com/apps/linear
on Jan 5, 2026https://github.com/getsentry/sentry-python/issues/5274#issuecomment-3709877523
Linearhttps://linear.app
PY-2023https://linear.app/getsentry/issue/PY-2023/django-asgi-send-default-pii-triggers-requestuseris-authenticated-sync
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Jan 5, 2026https://github.com/getsentry/sentry-python/issues/5274
sl0thentr0pyhttps://github.com/sl0thentr0py
Better Async Supporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Better%20Async%20Support%22
on Jan 7, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21900581885
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 Jan 7, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21900582715
sl0thentr0pyhttps://github.com/sl0thentr0py
Integration: Djangohttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20Django%22
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Jan 7, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21900583126
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 Jan 7, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21900583854
sl0thentr0pyhttps://github.com/sl0thentr0py
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
on Jan 7, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21900585117
sl0thentr0pyhttps://github.com/sl0thentr0py
on Jan 7, 2026https://github.com/getsentry/sentry-python/issues/5274#event-21900586657
https://github.com/sl0thentr0py
sl0thentr0pyhttps://github.com/sl0thentr0py
on Jan 26, 2026https://github.com/getsentry/sentry-python/issues/5274#issuecomment-3799369618
getsentry/repro#5https://github.com/getsentry/repro/pull/5
stephanie-andersonhttps://github.com/stephanie-anderson
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
on Mar 21, 2026https://github.com/getsentry/sentry-python/issues/5274#event-23774156790
dingsdaxhttps://github.com/dingsdax
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
on Mar 24, 2026https://github.com/getsentry/sentry-python/issues/5274#event-23842362011
alexander-alderman-webbhttps://github.com/alexander-alderman-webb
on Jun 10, 2026https://github.com/getsentry/sentry-python/issues/5274#event-26562167409
feat(django): Add user attributes in span streaming (#6541)https://github.com/getsentry/sentry-python/commit/4b35d66d8ef68d8577a990e4330f4e565aeba8df
#6541https://github.com/getsentry/sentry-python/pull/6541
4b35d66https://github.com/getsentry/sentry-python/commit/4b35d66d8ef68d8577a990e4330f4e565aeba8df
mgalignianahttps://github.com/mgaligniana
on Aug 9, 2026https://github.com/getsentry/sentry-python/issues/5274#event-29172584220
feat(django): Add user attributes in span streaming (getsentry#6541)https://github.com/mgaligniana/sentry-python/commit/11b5f6048e6dfebea7e3d36695f94b6371321345
getsentry#6541https://github.com/getsentry/sentry-python/pull/6541
11b5f60https://github.com/mgaligniana/sentry-python/commit/11b5f6048e6dfebea7e3d36695f94b6371321345
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-python/issues/5274
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/5274
sl0thentr0pyhttps://github.com/sl0thentr0py
Better Async Supporthttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Better%20Async%20Support%22
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
Integration: Djangohttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Integration%3A%20Django%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.