Skip to content

dont set on scope

86fd48a
Select commit
Loading
Failed to load commit list.
Merged

feat(wsgi): Migrate to span first #5988

dont set on scope
86fd48a
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Apr 13, 2026 in 2m 13s

2 issues

code-review: Found 2 issues (1 medium, 1 low)

Medium

span.set_attribute called on None causes silent AttributeError - `sentry_sdk/integrations/wsgi.py:167`

When the HTTP method is not in http_methods_to_capture, span_ctx becomes nullcontext() which yields None. The code then calls span.set_attribute(attr, value) on this None value at line 167. While wrapped in capture_internal_exceptions(), this causes a silent AttributeError that gets logged rather than crashing. The ASGI integration (lines 311-315) correctly guards this with if isinstance(span, StreamedSpan): before calling set_attribute().

Low

Unused crashing_app fixture in test function - `tests/integrations/wsgi/test_wsgi.py:145`

The crashing_app fixture is declared as a parameter in test_transaction_with_error but is never used. The test instead uses the locally defined dogpark function. This creates unnecessary fixture instantiation overhead and could cause confusion for future maintainers.


Duration: 2m 7s · Tokens: 1.6M in / 15.1k out · Cost: $2.05 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.01)

Annotations

Check warning on line 167 in sentry_sdk/integrations/wsgi.py

See this annotation in the file changed.

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

span.set_attribute called on None causes silent AttributeError

When the HTTP method is not in `http_methods_to_capture`, `span_ctx` becomes `nullcontext()` which yields `None`. The code then calls `span.set_attribute(attr, value)` on this `None` value at line 167. While wrapped in `capture_internal_exceptions()`, this causes a silent `AttributeError` that gets logged rather than crashing. The ASGI integration (lines 311-315) correctly guards this with `if isinstance(span, StreamedSpan):` before calling `set_attribute()`.