Skip to content

ref(strawberry): Simplify span creation#5647

Merged
sentrivana merged 3 commits into
masterfrom
ivana/fixup-strawberry-integration
Mar 12, 2026
Merged

ref(strawberry): Simplify span creation#5647
sentrivana merged 3 commits into
masterfrom
ivana/fixup-strawberry-integration

.

e28a436
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 12, 2026 in 1m 9s

1 issue

code-review: Found 1 issue (1 medium)

Medium

Span not closed if exception thrown into generator - `sentry_sdk/integrations/strawberry.py:189-204`

The manual __enter__() and __exit__(None, None, None) calls lack exception safety. If an exception is thrown into the generator at the yield point, the code after yield (including __exit__) won't execute, leaving the span unclosed and the scope in an inconsistent state (scope.span still points to this span). Additionally, always passing (None, None, None) to __exit__ means any exception that does reach that code won't be recorded on the span's status.


Duration: 1m 9s · Tokens: 182.1k in / 3.1k out · Cost: $0.27

Annotations

Check warning on line 204 in sentry_sdk/integrations/strawberry.py

See this annotation in the file changed.

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

Span not closed if exception thrown into generator

The manual `__enter__()` and `__exit__(None, None, None)` calls lack exception safety. If an exception is thrown into the generator at the `yield` point, the code after `yield` (including `__exit__`) won't execute, leaving the span unclosed and the scope in an inconsistent state (scope.span still points to this span). Additionally, always passing `(None, None, None)` to `__exit__` means any exception that does reach that code won't be recorded on the span's status.