Skip to content

fix(asgi): Stop duplicating scope["root_path"] in URLs#6579

Draft
alexander-alderman-webb wants to merge 11 commits into
masterfrom
webb/asgi/double-mount-prefix
Draft

fix(asgi): Stop duplicating scope["root_path"] in URLs#6579
alexander-alderman-webb wants to merge 11 commits into
masterfrom
webb/asgi/double-mount-prefix

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

Add the path_includes_root_path boolean parameter to _get_url() and related functions.

If the parameter is True (the default), scope["path"] is considered to include scope["root_path"], where scope is the ASGI scope. Otherwise, the existing behavior that prepends scope["root_path"] when forming the url is preserved.

Add tests to each ASGI-based integration. Some are compliant with the ASGI spec in which scope["path"] includes scope["root_path"], while others are not. In particular, Starlite, LiterStar and old versions of Starlette are not compliant with the spec. In these cases, path_includes_root_path=False is set.

Issues

Closes #6577

Reminders

Comment thread sentry_sdk/integrations/_asgi_common.py
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

90500 passed | ⏭️ 6124 skipped | Total: 96624 | Pass Rate: 93.66% | Execution Time: 320m 23s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -331
Passed Tests 📉 -326
Failed Tests
Skipped Tests 📉 -5

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2409 uncovered lines.
✅ Project coverage is 89.86%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/quart.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.85%    89.86%    +0.01%
==========================================
  Files          192       192         —
  Lines        23745     23748        +3
  Branches      8198      8198         —
==========================================
+ Hits         21334     21339        +5
- Misses        2411      2409        -2
- Partials      1344      1344         —

Generated by Codecov Action

Comment thread tests/integrations/starlette/test_starlette.py
Comment thread tests/integrations/starlite/test_starlite.py
Comment thread tests/integrations/litestar/test_litestar.py
Comment thread sentry_sdk/integrations/asgi.py
Comment thread tests/integrations/django/asgi/test_asgi.py
@alexander-alderman-webb alexander-alderman-webb changed the title fix(asgi): Stop duplicating root_path in URLs fix(asgi): Stop duplicating scope["root_path"] in URLs Jun 19, 2026
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.

ASGI integration doubles the mount prefix in request.url for Starlette Mounted sub-apps (root_path + path)

1 participant