fix(asgi): Stop duplicating `scope["root_path"]` in URLs by alexander-alderman-webb · Pull Request #6579 · getsentry/sentry-python
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 and Quart are not compliant with the spec. In these cases, path_includes_root_path=False is set.
Issues
Closes #6577
Reminders
- Please add tests to validate your changes, and lint your code using
uv run ruff. - Add GH Issue ID & Linear ID (if applicable)
- PR title should use conventional commit style (
feat:,fix:,ref:,meta:) - For external contributors: CONTRIBUTING.md, Sentry SDK development docs, Discord community