feat(asgi): Migrate away from event processor in span first #5920
3 issues
find-bugs: Found 3 issues (1 medium, 2 low)
Medium
AnnotatedValue objects stored as span attributes instead of valid AttributeValue types - `sentry_sdk/integrations/_asgi_common.py:124-125`
When should_send_default_pii() returns False, _filter_headers() returns sensitive header values as AnnotatedValue objects (see _wsgi_common.py:218-225). The new code at line 124-125 stores these directly into attributes without checking if they're AnnotatedValue instances. Since AnnotatedValue is not a valid AttributeValue type (which only accepts primitives and lists/tuples of primitives), this will cause type errors or unexpected serialization behavior when the attributes are processed downstream.
Low
None value may be stored as http.query attribute violating AttributeValue type - `sentry_sdk/integrations/_asgi_common.py:127`
_get_query() returns None when there is no query string (lines 64-66 in _get_query). The new code at line 127 unconditionally assigns this to attributes["http.query"], but None is not a valid AttributeValue type. This could cause serialization issues or type errors downstream when processing span attributes.
StreamedSpan name/source not updated when request raises exception - `sentry_sdk/integrations/asgi.py:349-357`
The new code at lines 349-355 that updates the segment name and source for StreamedSpans only executes on the success path after await self.app(...) returns. If the application raises an exception, the segment name update is skipped, and the span will be recorded with its initial generic name instead of the refined endpoint-based name. The existing event_processor (line 222-223) still processes error events for non-StreamedSpan flows, but StreamedSpans bypass this.
Duration: 4m 8s · Tokens: 1.1M in / 11.8k out · Cost: $1.49 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.00)
Annotations
Check warning on line 125 in sentry_sdk/integrations/_asgi_common.py
sentry-warden / warden: find-bugs
AnnotatedValue objects stored as span attributes instead of valid AttributeValue types
When `should_send_default_pii()` returns False, `_filter_headers()` returns sensitive header values as `AnnotatedValue` objects (see `_wsgi_common.py:218-225`). The new code at line 124-125 stores these directly into attributes without checking if they're `AnnotatedValue` instances. Since `AnnotatedValue` is not a valid `AttributeValue` type (which only accepts primitives and lists/tuples of primitives), this will cause type errors or unexpected serialization behavior when the attributes are processed downstream.