Skip to content

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

Merged
alexander-alderman-webb merged 22 commits into
masterfrom
webb/asgi/double-mount-prefix
Jun 26, 2026
Merged

fix(starlette): Stop duplicating scope["root_path"] in URLs#6579
alexander-alderman-webb merged 22 commits into
masterfrom
webb/asgi/double-mount-prefix

remove default arguments

557c418
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Jun 26, 2026 in 0s

2 issues

code-review: Found 2 issues (2 medium)

Medium

No tests covering the new `root_path_in_path` behavior in any of the changed test files

The PR description states tests were added for root_path handling in each ASGI integration, but none of the changed test files (test_asgi.py, test_fastapi.py, test_starlette.py) contain any tests exercising root_path or the EITHER/EXCLUDED enum paths. Have you considered adding at least one test that sets root_path in the ASGI scope and asserts the resulting URL is not duplicated?

New `root_path` deduplication logic in `_get_path()` has no test coverage - `sentry_sdk/integrations/asgi.py:122`

The PR adds a root_path_in_path parameter and a _RootPathInPath.EITHER branch in _get_path() (sentry_sdk/integrations/_asgi_common.py) to avoid duplicating scope["root_path"] in URLs. The branch performs non-trivial prefix detection (path.startswith(root_path + "/")) and the Starlette integration selects between EXCLUDED and EITHER based on the Starlette version (>= (0, 33)). Despite the PR description stating that tests were added to each ASGI integration, no test in the suite exercises this logic: there are zero references to root_path in any test file. The version-sensitive, prefix-detecting behavior is therefore regression-prone, with edge cases (e.g. root_path="/api", path="/api-docs") silently untested.

Also found at:

  • sentry_sdk/integrations/asgi.py:18
  • sentry_sdk/integrations/starlette.py:457
  • tests/integrations/starlette/test_starlette.py:1507

⏱ 8m 26s · 3.8M in / 132.6k out · $4.92

Annotations

Check warning on line 122 in sentry_sdk/integrations/asgi.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

New `root_path` deduplication logic in `_get_path()` has no test coverage

The PR adds a `root_path_in_path` parameter and a `_RootPathInPath.EITHER` branch in `_get_path()` (`sentry_sdk/integrations/_asgi_common.py`) to avoid duplicating `scope["root_path"]` in URLs. The branch performs non-trivial prefix detection (`path.startswith(root_path + "/")`) and the Starlette integration selects between `EXCLUDED` and `EITHER` based on the Starlette version (`>= (0, 33)`). Despite the PR description stating that tests were added to each ASGI integration, no test in the suite exercises this logic: there are zero references to `root_path` in any test file. The version-sensitive, prefix-detecting behavior is therefore regression-prone, with edge cases (e.g. `root_path="/api"`, `path="/api-docs"`) silently untested.

Check warning on line 18 in sentry_sdk/integrations/asgi.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[687-F25] New `root_path` deduplication logic in `_get_path()` has no test coverage (additional location)

The PR adds a `root_path_in_path` parameter and a `_RootPathInPath.EITHER` branch in `_get_path()` (`sentry_sdk/integrations/_asgi_common.py`) to avoid duplicating `scope["root_path"]` in URLs. The branch performs non-trivial prefix detection (`path.startswith(root_path + "/")`) and the Starlette integration selects between `EXCLUDED` and `EITHER` based on the Starlette version (`>= (0, 33)`). Despite the PR description stating that tests were added to each ASGI integration, no test in the suite exercises this logic: there are zero references to `root_path` in any test file. The version-sensitive, prefix-detecting behavior is therefore regression-prone, with edge cases (e.g. `root_path="/api"`, `path="/api-docs"`) silently untested.

Check warning on line 457 in sentry_sdk/integrations/starlette.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[687-F25] New `root_path` deduplication logic in `_get_path()` has no test coverage (additional location)

The PR adds a `root_path_in_path` parameter and a `_RootPathInPath.EITHER` branch in `_get_path()` (`sentry_sdk/integrations/_asgi_common.py`) to avoid duplicating `scope["root_path"]` in URLs. The branch performs non-trivial prefix detection (`path.startswith(root_path + "/")`) and the Starlette integration selects between `EXCLUDED` and `EITHER` based on the Starlette version (`>= (0, 33)`). Despite the PR description stating that tests were added to each ASGI integration, no test in the suite exercises this logic: there are zero references to `root_path` in any test file. The version-sensitive, prefix-detecting behavior is therefore regression-prone, with edge cases (e.g. `root_path="/api"`, `path="/api-docs"`) silently untested.

Check warning on line 1507 in tests/integrations/starlette/test_starlette.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[687-F25] New `root_path` deduplication logic in `_get_path()` has no test coverage (additional location)

The PR adds a `root_path_in_path` parameter and a `_RootPathInPath.EITHER` branch in `_get_path()` (`sentry_sdk/integrations/_asgi_common.py`) to avoid duplicating `scope["root_path"]` in URLs. The branch performs non-trivial prefix detection (`path.startswith(root_path + "/")`) and the Starlette integration selects between `EXCLUDED` and `EITHER` based on the Starlette version (`>= (0, 33)`). Despite the PR description stating that tests were added to each ASGI integration, no test in the suite exercises this logic: there are zero references to `root_path` in any test file. The version-sensitive, prefix-detecting behavior is therefore regression-prone, with edge cases (e.g. `root_path="/api"`, `path="/api-docs"`) silently untested.