Skip to content

fix(aiohttp): Gate url.full, url.path, url.query on send_default_pii#6650

Open
ericapisani wants to merge 2 commits into
masterfrom
py-2545-aiohttp-url-attr
Open

fix(aiohttp): Gate url.full, url.path, url.query on send_default_pii#6650
ericapisani wants to merge 2 commits into
masterfrom
py-2545-aiohttp-url-attr

Conversation

@ericapisani

@ericapisani ericapisani commented Jun 24, 2026

Copy link
Copy Markdown
Member

URL attributes (url.full, url.path, url.query) contain potentially sensitive data — full request URLs, path segments, and query strings — that should not be captured unless the user has explicitly opted in to PII collection. Previously these were always recorded on both server and outgoing client spans.

This gates all three attributes behind should_send_default_pii() for both span types, matching the behavior of client.address and user.ip_address that were already gated. Tests for the two streaming span cases are parametrized to cover both PII-on and PII-off paths.

Fixes PY-2545
Fixes #6631

URL attributes (url.full, url.path, url.query) contain potentially
sensitive data (full request URLs, paths, query strings) that should
not be captured unless the user has opted in to sending PII.

Gate these attributes behind send_default_pii() for both server and
outgoing client spans to match the behavior of other integrations.

Refs PY-2545
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 24, 2026

Copy link
Copy Markdown

PY-2545

@ericapisani ericapisani marked this pull request as ready for review June 24, 2026 13:41
@ericapisani ericapisani requested a review from a team as a code owner June 24, 2026 13:41

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a07b0be. Configure here.

Comment thread sentry_sdk/integrations/aiohttp.py Outdated
Comment thread sentry_sdk/integrations/aiohttp.py Outdated
Comment thread sentry_sdk/integrations/aiohttp.py Outdated
Comment thread tests/integrations/aiohttp/test_aiohttp.py
Comment thread sentry_sdk/integrations/aiohttp.py


@pytest.mark.asyncio
@pytest.mark.parametrize("send_pii", [True, False])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parametrized send_pii=False path has no assertions — the PII-off behavior is untested

The send_pii=False parametrized case runs with no assertions after line 1557, so the test won't catch a regression where URL attributes are still included when PII is disabled. Consider adding an else branch asserting url.full, url.path, and url.query are absent from inner_client_span["attributes"].

Evidence
  • The hunk at line 1505 adds @pytest.mark.parametrize("send_pii", [True, False]) to gate assertions.
  • The assertions from lines 1559–1569 are under if send_pii: with no else branch.
  • When send_pii=False, the test passes unconditionally after validating only http.request.method, http.response.status_code, and status.
  • A regression in aiohttp.py that leaves URL attributes on the span regardless of PII would not be caught by this test case.
Also found at 1 additional location
  • tests/integrations/aiohttp/test_aiohttp.py:1559-1571

Identified by Warden code-review · Q2F-VZM

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

89870 passed | ⏭️ 6240 skipped | Total: 96110 | Pass Rate: 93.51% | Execution Time: 318m 51s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +33
Passed Tests 📈 +33
Failed Tests
Skipped Tests

All tests are passing successfully.

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

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.89%    89.92%    +0.03%
==========================================
  Files          192       192         —
  Lines        23763     23769        +6
  Branches      8206      8210        +4
==========================================
+ Hits         21360     21373       +13
- Misses        2403      2396        -7
- Partials      1343      1342        -1

Generated by Codecov Action

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.

aiohttp missing url.pathattribute

1 participant