Skip to content

ref(integrations): route HTTP header filtering through data collection config#6788

Draft
ericapisani wants to merge 1 commit into
masterfrom
py-2584-update-wsgi-filter-headers
Draft

ref(integrations): route HTTP header filtering through data collection config#6788
ericapisani wants to merge 1 commit into
masterfrom
py-2584-update-wsgi-filter-headers

Conversation

@ericapisani

Copy link
Copy Markdown
Member

_filter_headers previously used a hardcoded sensitive-header tuple and a send_default_pii/use_annotated_value toggle. It now delegates to _apply_key_value_collection_filtering from sentry_sdk.data_collection, so header scrubbing respects the new data_collection.http_headers.request allowlist/denylist/off configuration.

Cookie and set-cookie headers are
always redacted regardless of mode. Drops the now-unused use_annotated_value parameter from all call sites.

Work to scrub cookies in a more granular way will be tackled as part of PY-2581/#6741.

Fixes PY-2584
Fixes #6744

…n config

`_filter_headers` previously used a hardcoded sensitive-header tuple and a
`send_default_pii`/`use_annotated_value` toggle. It now delegates to
`_apply_key_value_collection_filtering` from `sentry_sdk.data_collection`,
so header scrubbing respects the new `data_collection.http_headers.request`
allowlist/denylist/off configuration.

Cookie and set-cookie headers are
always redacted regardless of mode. Drops the now-unused
`use_annotated_value` parameter from all call sites.

Work to scrub cookies in a more granular way will be tackled as part of
PY-2581/#6741.

Fixes PY-2584
Fixes #6744
@linear-code

linear-code Bot commented Jul 8, 2026

Copy link
Copy Markdown

PY-2584

PY-2581

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

88851 passed | ❌ 20 failed | ⏭️ 6220 skipped | Total: 95091 | Pass Rate: 93.44% | Execution Time: 307m 35s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -2156
Passed Tests 📉 -2094
Failed Tests 📈 +20
Skipped Tests 📉 -82

➕ New Tests (20)

View new tests
  • test_non_dict_event[event as dict]
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_request_data
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_capture_transaction[True-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_capture_transaction[False-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_capture_transaction[True-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_capture_transaction[False-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_non_dict_event[event as dict]
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_request_data
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_capture_transaction[True-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_capture_transaction[False-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_capture_transaction[True-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_capture_transaction[False-False]
    • File: tests.integrations.asgi.test_asgi
    • Status: ❌ Failing
  • test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]
    • File: tests.integrations.aiohttp.test_aiohttp
    • Status: ❌ Failing
  • test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]
    • File: tests.integrations.aiohttp.test_aiohttp
    • Status: ❌ Failing
  • test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]
    • File: tests.integrations.aiohttp.test_aiohttp
    • Status: ❌ Failing
  • test_non_dict_event[event as dict]
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_request_data
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]
    • File: tests.integrations.aiohttp.test_aiohttp
    • Status: ❌ Failing
  • test_non_dict_event[event as dict]
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing
  • test_request_data
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing

❌ Failed Tests

test_non_dict_event[event as dict]

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.11-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}} Common items: {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
 Differing items: {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}} Full diff: { - 'headers': { - 'Host': 'x1.io', - 'X-Forwarded-Proto': 'https', - }, 'method': 'GET', 'url': 'https://x1.io/1',
 'query_string': { 'done': 'f', }, + 'headers': { + 'Host': 'x1.io', + 'X-Forwarded-Proto': '[Filtered]', + }, }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:347: in test_non_dict_event
    assert error_event["request"] == request_data
E   AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}}
E     
E     Common items:
E     {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
E     Differing items:
E     {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E     -     'headers': {
E     -         'Host': 'x1.io',
E     -         'X-Forwarded-Proto': 'https',
E     -     },
E           'method': 'GET',
E           'url': 'https://x1.io/1',
E           'query_string': {
E               'done': 'f',
E           },
E     +     'headers': {
E     +         'Host': 'x1.io',
E     +         'X-Forwarded-Proto': '[Filtered]',
E     +     },
E       }

test_request_data

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.11-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Common items: {'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Differing items: {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}} Full diff: { + 'method': 'GET', + 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
 + 'query_string': { + 'bonkers': 'true', + }, 'headers': { 'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', - 'X-Forwarded-Proto': 'https', ? ^ ^^^ + 'X-Forwarded-Proto': '[Filtered]', ? ^^^^ ^^^^^ }, - 'method': 'GET', - 'query_string': { - 'bonkers': 'true', - }, - 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
 }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:392: in test_request_data
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': {'bonkers': 'true'},
E      'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     Differing items:
E     {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E     +     'method': 'GET',
E     +     'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
E     +     'query_string': {
E     +         'bonkers': 'true',
E     +     },
E           'headers': {
E               'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com',
E               'User-Agent': 'custom',
E     -         'X-Forwarded-Proto': 'https',
E     ?                               ^ ^^^
E     +         'X-Forwarded-Proto': '[Filtered]',
E     ?                               ^^^^ ^^^^^
E           },
E     -     'method': 'GET',
E     -     'query_string': {
E     -         'bonkers': 'true',
E     -     },
E     -     'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
E       }

test_capture_transaction[True-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.12-asgi
Error: AssertionError: assert '[Filtered]' == '127.0.0.1' - 127.0.0.1 + [Filtered]

Stack Trace
tests/integrations/asgi/test_asgi.py:214: in test_capture_transaction
    assert span["attributes"]["http.request.header.remote-addr"] == "127.0.0.1"
E   AssertionError: assert '[Filtered]' == '127.0.0.1'
E     
E     - 127.0.0.1
E     + [Filtered]

test_capture_transaction[False-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.12-asgi
Error: AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Common items: {'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Differing items: {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}} Full diff: { + 'method': 'GET', 'headers': { + 'remote-addr': '[Filtered]', + 'user-agent': 'ASGI-Test-Client', 'host': 'localhost', - 'remote-addr': '127.0.0.1', - 'user-agent': 'ASGI-Test-Client', }, - 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url',
 }

Stack Trace
tests/integrations/asgi/test_asgi.py:234: in test_capture_transaction
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': 'somevalue=123',
E      'url': 'http://localhost/some_url'}
E     Differing items:
E     {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}}
E     
E     Full diff:
E       {
E     +     'method': 'GET',
E           'headers': {
E     +         'remote-addr': '[Filtered]',
E     +         'user-agent': 'ASGI-Test-Client',
E               'host': 'localhost',
E     -         'remote-addr': '127.0.0.1',
E     -         'user-agent': 'ASGI-Test-Client',
E           },
E     -     'method': 'GET',
E           'query_string': 'somevalue=123',
E           'url': 'http://localhost/some_url',
E       }

test_capture_transaction[True-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.13-asgi
Error: AssertionError: assert '[Filtered]' == '127.0.0.1' - 127.0.0.1 + [Filtered]

Stack Trace
tests/integrations/asgi/test_asgi.py:214: in test_capture_transaction
    assert span["attributes"]["http.request.header.remote-addr"] == "127.0.0.1"
E   AssertionError: assert '[Filtered]' == '127.0.0.1'
E     
E     - 127.0.0.1
E     + [Filtered]

test_capture_transaction[False-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.13-asgi
Error: AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Common items: {'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Differing items: {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}} Full diff: { + 'method': 'GET', 'headers': { + 'remote-addr': '[Filtered]', + 'user-agent': 'ASGI-Test-Client', 'host': 'localhost', - 'remote-addr': '127.0.0.1', - 'user-agent': 'ASGI-Test-Client', }, - 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url',
 }

Stack Trace
tests/integrations/asgi/test_asgi.py:234: in test_capture_transaction
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': 'somevalue=123',
E      'url': 'http://localhost/some_url'}
E     Differing items:
E     {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}}
E     
E     Full diff:
E       {
E     +     'method': 'GET',
E           'headers': {
E     +         'remote-addr': '[Filtered]',
E     +         'user-agent': 'ASGI-Test-Client',
E               'host': 'localhost',
E     -         'remote-addr': '127.0.0.1',
E     -         'user-agent': 'ASGI-Test-Client',
E           },
E     -     'method': 'GET',
E           'query_string': 'somevalue=123',
E           'url': 'http://localhost/some_url',
E       }

test_non_dict_event[event as dict]

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.13-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}} Common items: {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
 Differing items: {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}} Full diff: { - 'headers': { - 'Host': 'x1.io', - 'X-Forwarded-Proto': 'https', - }, 'method': 'GET', 'url': 'https://x1.io/1',
 'query_string': { 'done': 'f', }, + 'headers': { + 'Host': 'x1.io', + 'X-Forwarded-Proto': '[Filtered]', + }, }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:347: in test_non_dict_event
    assert error_event["request"] == request_data
E   AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}}
E     
E     Common items:
E     {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
E     Differing items:
E     {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E     -     'headers': {
E     -         'Host': 'x1.io',
E     -         'X-Forwarded-Proto': 'https',
E     -     },
E           'method': 'GET',
E           'url': 'https://x1.io/1',
E           'query_string': {
E               'done': 'f',
E           },
E     +     'headers': {
E     +         'Host': 'x1.io',
E     +         'X-Forwarded-Proto': '[Filtered]',
E     +     },
E       }

test_request_data

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.13-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Common items: {'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Differing items: {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}} Full diff: { + 'method': 'GET', + 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
 + 'query_string': { + 'bonkers': 'true', + }, 'headers': { 'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', - 'X-Forwarded-Proto': 'https', ? ^ ^^^ + 'X-Forwarded-Proto': '[Filtered]', ? ^^^^ ^^^^^ }, - 'method': 'GET', - 'query_string': { - 'bonkers': 'true', - }, - 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
 }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:392: in test_request_data
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': {'bonkers': 'true'},
E      'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     Differing items:
E     {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E     +     'method': 'GET',
E     +     'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
E     +     'query_string': {
E     +         'bonkers': 'true',
E     +     },
E           'headers': {
E               'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com',
E               'User-Agent': 'custom',
E     -         'X-Forwarded-Proto': 'https',
E     ?                               ^ ^^^
E     +         'X-Forwarded-Proto': '[Filtered]',
E     ?                               ^^^^ ^^^^^
E           },
E     -     'method': 'GET',
E     -     'query_string': {
E     -         'bonkers': 'true',
E     -     },
E     -     'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
E       }

test_capture_transaction[True-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.14-asgi
Error: AssertionError: assert '[Filtered]' == '127.0.0.1' - 127.0.0.1 + [Filtered]

Stack Trace
tests/integrations/asgi/test_asgi.py:214: in test_capture_transaction
    assert span["attributes"]["http.request.header.remote-addr"] == "127.0.0.1"
E   AssertionError: assert '[Filtered]' == '127.0.0.1'
E     
E     - 127.0.0.1
E     + [Filtered]

test_capture_transaction[False-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.14-asgi
Error: AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Common items: {'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Differing items: {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}} Full diff: { + 'method': 'GET', 'headers': { + 'remote-addr': '[Filtered]', + 'user-agent': 'ASGI-Test-Client', 'host': 'localhost', - 'remote-addr': '127.0.0.1', - 'user-agent': 'ASGI-Test-Client', }, - 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url',
 }

Stack Trace
tests/integrations/asgi/test_asgi.py:234: in test_capture_transaction
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': 'somevalue=123',
E      'url': 'http://localhost/some_url'}
E     Differing items:
E     {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}}
E     
E     Full diff:
E       {
E     +     'method': 'GET',
E           'headers': {
E     +         'remote-addr': '[Filtered]',
E     +         'user-agent': 'ASGI-Test-Client',
E               'host': 'localhost',
E     -         'remote-addr': '127.0.0.1',
E     -         'user-agent': 'ASGI-Test-Client',
E           },
E     -     'method': 'GET',
E           'query_string': 'somevalue=123',
E           'url': 'http://localhost/some_url',
E       }

test_capture_transaction[True-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.14t-asgi
Error: AssertionError: assert '[Filtered]' == '127.0.0.1' - 127.0.0.1 + [Filtered]

Stack Trace
tests/integrations/asgi/test_asgi.py:214: in test_capture_transaction
    assert span["attributes"]["http.request.header.remote-addr"] == "127.0.0.1"
E   AssertionError: assert '[Filtered]' == '127.0.0.1'
E     
E     - 127.0.0.1
E     + [Filtered]

test_capture_transaction[False-False]

File: tests.integrations.asgi.test_asgi
Suite: py3.14t-asgi
Error: AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Common items: {'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
 Differing items: {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}} Full diff: { + 'method': 'GET', 'headers': { + 'remote-addr': '[Filtered]', + 'user-agent': 'ASGI-Test-Client', 'host': 'localhost', - 'remote-addr': '127.0.0.1', - 'user-agent': 'ASGI-Test-Client', }, - 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url',
 }

Stack Trace
tests/integrations/asgi/test_asgi.py:234: in test_capture_transaction
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}, 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'} == {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}, 'method': 'GET', 'query_string': 'somevalue=123', 'url': 'http://localhost/some_url'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': 'somevalue=123',
E      'url': 'http://localhost/some_url'}
E     Differing items:
E     {'headers': {'remote-addr': '[Filtered]', 'user-agent': 'ASGI-Test-Client', 'host': 'localhost'}} != {'headers': {'host': 'localhost', 'remote-addr': '127.0.0.1', 'user-agent': 'ASGI-Test-Client'}}
E     
E     Full diff:
E       {
E     +     'method': 'GET',
E           'headers': {
E     +         'remote-addr': '[Filtered]',
E     +         'user-agent': 'ASGI-Test-Client',
E               'host': 'localhost',
E     -         'remote-addr': '127.0.0.1',
E     -         'user-agent': 'ASGI-Test-Client',
E           },
E     -     'method': 'GET',
E           'query_string': 'somevalue=123',
E           'url': 'http://localhost/some_url',
E       }

test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]

File: tests.integrations.aiohttp.test_aiohttp
Suite: py3.7-aiohttp-v3.4.4
Error: KeyError: 'http.request.header.authorization'

Stack Trace
tests/integrations/aiohttp/test_aiohttp.py:1412: in test_sensitive_header_passthrough_with_pii_span_streaming
    assert (
E   KeyError: 'http.request.header.authorization'

test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]

File: tests.integrations.aiohttp.test_aiohttp
Suite: py3.7-aiohttp-v3.7.4
Error: KeyError: 'http.request.header.authorization'

Stack Trace
tests/integrations/aiohttp/test_aiohttp.py:1412: in test_sensitive_header_passthrough_with_pii_span_streaming
    assert (
E   KeyError: 'http.request.header.authorization'

test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]

File: tests.integrations.aiohttp.test_aiohttp
Suite: py3.8-aiohttp-v3.7.4
Error: KeyError: 'http.request.header.authorization'

Stack Trace
tests/integrations/aiohttp/test_aiohttp.py:1413: in test_sensitive_header_passthrough_with_pii_span_streaming
    server_span["attributes"]["http.request.header.authorization"]
E   KeyError: 'http.request.header.authorization'

test_non_dict_event[event as dict]

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.8-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}} Common items: {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
 Differing items: {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}} Full diff: { 'headers': { 'Host': 'x1.io', - 'X-Forwarded-Proto': 'https', ? ^ ^^^ + 'X-Forwarded-Proto': '[Filtered]', ? ^^^^ ^^^^^ }, 'method': 'GET', 'query_string': { 'done': 'f', }, 'url': 'https://x1.io/1',
 }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:347: in test_non_dict_event
    assert error_event["request"] == request_data
E   AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}}
E     
E     Common items:
E     {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
E     Differing items:
E     {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E           'headers': {
E               'Host': 'x1.io',
E     -         'X-Forwarded-Proto': 'https',
E     ?                               ^ ^^^
E     +         'X-Forwarded-Proto': '[Filtered]',
E     ?                               ^^^^ ^^^^^
E           },
E           'method': 'GET',
E           'query_string': {
E               'done': 'f',
E           },
E           'url': 'https://x1.io/1',
E       }

test_request_data

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.8-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Common items: {'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Differing items: {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}} Full diff: { 'headers': { 'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', - 'X-Forwarded-Proto': 'https', ? ^ ^^^ + 'X-Forwarded-Proto': '[Filtered]', ? ^^^^ ^^^^^ }, 'method': 'GET', 'query_string': { 'bonkers': 'true', }, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
 }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:392: in test_request_data
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': {'bonkers': 'true'},
E      'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     Differing items:
E     {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E           'headers': {
E               'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com',
E               'User-Agent': 'custom',
E     -         'X-Forwarded-Proto': 'https',
E     ?                               ^ ^^^
E     +         'X-Forwarded-Proto': '[Filtered]',
E     ?                               ^^^^ ^^^^^
E           },
E           'method': 'GET',
E           'query_string': {
E               'bonkers': 'true',
E           },
E           'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
E       }

test_sensitive_header_passthrough_with_pii_span_streaming[pyloop-data_collection_off_does_not_add_headers]

File: tests.integrations.aiohttp.test_aiohttp
Suite: py3.9-aiohttp-v3.7.4
Error: KeyError: 'http.request.header.authorization'

Stack Trace
tests/integrations/aiohttp/test_aiohttp.py:1413: in test_sensitive_header_passthrough_with_pii_span_streaming
    server_span["attributes"]["http.request.header.authorization"]
E   KeyError: 'http.request.header.authorization'

test_non_dict_event[event as dict]

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.9-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}} Common items: {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
 Differing items: {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}} Full diff: { 'headers': { 'Host': 'x1.io', - 'X-Forwarded-Proto': 'https', ? ^ ^^^ + 'X-Forwarded-Proto': '[Filtered]', ? ^^^^ ^^^^^ }, 'method': 'GET', 'query_string': { 'done': 'f', }, 'url': 'https://x1.io/1',
 }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:347: in test_non_dict_event
    assert error_event["request"] == request_data
E   AssertionError: assert {'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}, 'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'url': 'https://x1.io/1', 'query_string': {'done': 'f'}}
E     
E     Common items:
E     {'method': 'GET', 'query_string': {'done': 'f'}, 'url': 'https://x1.io/1'}
E     Differing items:
E     {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'x1.io', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E           'headers': {
E               'Host': 'x1.io',
E     -         'X-Forwarded-Proto': 'https',
E     ?                               ^ ^^^
E     +         'X-Forwarded-Proto': '[Filtered]',
E     ?                               ^^^^ ^^^^^
E           },
E           'method': 'GET',
E           'query_string': {
E               'done': 'f',
E           },
E           'url': 'https://x1.io/1',
E       }

test_request_data

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.9-aws_lambda
Error: AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Common items: {'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
 Differing items: {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}} Full diff: { 'headers': { 'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', - 'X-Forwarded-Proto': 'https', ? ^ ^^^ + 'X-Forwarded-Proto': '[Filtered]', ? ^^^^ ^^^^^ }, 'method': 'GET', 'query_string': { 'bonkers': 'true', }, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
 }

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:392: in test_request_data
    assert transaction_event["request"] == {
E   AssertionError: assert {'method': 'GET', 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd', 'query_string': {'bonkers': 'true'}, 'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} == {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}, 'method': 'GET', 'query_string': {'bonkers': 'true'}, 'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     
E     Common items:
E     {'method': 'GET',
E      'query_string': {'bonkers': 'true'},
E      'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd'}
E     Differing items:
E     {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': '[Filtered]'}} != {'headers': {'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com', 'User-Agent': 'custom', 'X-Forwarded-Proto': 'https'}}
E     
E     Full diff:
E       {
E           'headers': {
E               'Host': 'iwsz2c7uwi.execute-api.us-east-1.amazonaws.com',
E               'User-Agent': 'custom',
E     -         'X-Forwarded-Proto': 'https',
E     ?                               ^ ^^^
E     +         'X-Forwarded-Proto': '[Filtered]',
E     ?                               ^^^^ ^^^^^
E           },
E           'method': 'GET',
E           'query_string': {
E               'bonkers': 'true',
E           },
E           'url': 'https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd',
E       }

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

Files with missing lines (1)
File Patch % Lines
sentry_sdk/data_collection.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.78%    89.78%        —%
==========================================
  Files          193       193         —
  Lines        23876     23907       +31
  Branches      8244      8270       +26
==========================================
+ Hits         21437     21464       +27
- Misses        2439      2443        +4
- Partials      1351      1353        +2

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.

Update _filter_headers to check data collection settings when available

1 participant