ref(strawberry): Simplify span creation#5647
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
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.