Skip to content

.

b270e5a
Select commit
Loading
Failed to load commit list.
Draft

feat(asgi): Migrate away from event processor in span first #5920

.
b270e5a
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Apr 1, 2026 in 5m 22s

4 issues

find-bugs: Found 4 issues (1 high, 3 medium)

High

Test parameterization has duplicate values - span_streaming path never tested - `tests/integrations/asgi/test_asgi.py:170`

The parametrize decorator on line 170 uses [[False, True], [False, True]] which creates two identical test cases with span_streaming=False, send_default_pii=True. This means the new span streaming code path (lines 198-222) will never be executed. The intended parameterization should test all combinations: [[False, False], [False, True], [True, False], [True, True]] or at least include span_streaming=True cases.

Medium

AnnotatedValue objects from _filter_headers are not properly handled in attributes - `sentry_sdk/integrations/_asgi_common.py:123-124`

_get_request_attributes iterates over headers from _filter_headers and directly assigns values to attributes. When should_send_default_pii() returns False, _filter_headers returns AnnotatedValue objects for sensitive headers (cookies, authorization, etc.). These objects are passed to set_attribute(), which calls format_attribute() -> safe_repr(), resulting in unhelpful string representations like '<AnnotatedValue object>' instead of proper redaction handling. While no actual PII is leaked (AnnotatedValue.value is empty), the behavior is inconsistent with _get_request_data and produces meaningless attribute values.

Attribute name mismatch between code and test - `sentry_sdk/integrations/asgi.py:244`

The code sets network.protocol.name as the attribute key, but the test test_capture_transaction in tests/integrations/asgi/test_asgi.py line 217 expects the attribute to be http.request.protocol.name. This will cause the test to fail when span streaming is enabled, as the test assertion span["attributes"]["http.request.protocol.name"] == "http" will not find the expected key.

KeyError when span has no attributes - `tests/conftest.py:1230-1232`

The envelopes_to_spans function directly accesses span_json["attributes"] without checking if the key exists. In _span_batcher.py line 116, the attributes field is only included in the transport format when item._attributes is truthy (non-empty). If a span has no attributes set, span_json["attributes"] will not exist, causing a KeyError when the function tries to iterate over it.


Duration: 5m 14s · Tokens: 3.6M in / 23.5k out · Cost: $4.22 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01)

Annotations

Check failure on line 170 in tests/integrations/asgi/test_asgi.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

Test parameterization has duplicate values - span_streaming path never tested

The parametrize decorator on line 170 uses `[[False, True], [False, True]]` which creates two identical test cases with `span_streaming=False, send_default_pii=True`. This means the new span streaming code path (lines 198-222) will never be executed. The intended parameterization should test all combinations: `[[False, False], [False, True], [True, False], [True, True]]` or at least include `span_streaming=True` cases.

Check warning on line 124 in sentry_sdk/integrations/_asgi_common.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

AnnotatedValue objects from _filter_headers are not properly handled in attributes

_get_request_attributes iterates over headers from _filter_headers and directly assigns values to attributes. When should_send_default_pii() returns False, _filter_headers returns AnnotatedValue objects for sensitive headers (cookies, authorization, etc.). These objects are passed to set_attribute(), which calls format_attribute() -&gt; safe_repr(), resulting in unhelpful string representations like '&lt;AnnotatedValue object&gt;' instead of proper redaction handling. While no actual PII is leaked (AnnotatedValue.value is empty), the behavior is inconsistent with _get_request_data and produces meaningless attribute values.

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

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

Attribute name mismatch between code and test

The code sets `network.protocol.name` as the attribute key, but the test `test_capture_transaction` in `tests/integrations/asgi/test_asgi.py` line 217 expects the attribute to be `http.request.protocol.name`. This will cause the test to fail when span streaming is enabled, as the test assertion `span["attributes"]["http.request.protocol.name"] == "http"` will not find the expected key.

Check warning on line 1232 in tests/conftest.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

KeyError when span has no attributes

The `envelopes_to_spans` function directly accesses `span_json["attributes"]` without checking if the key exists. In `_span_batcher.py` line 116, the `attributes` field is only included in the transport format when `item._attributes` is truthy (non-empty). If a span has no attributes set, `span_json["attributes"]` will not exist, causing a `KeyError` when the function tries to iterate over it.