ref(strawberry): Simplify span creation #5647
1 issue
find-bugs: Found 1 issue (1 medium)
Medium
Span context manager not properly closed on exception - span leaks and scope corruption - `sentry_sdk/integrations/strawberry.py:189-204`
The new code calls self.graphql_span.__enter__() at line 189 and self.graphql_span.__exit__(None, None, None) at line 204, but if an exception is thrown into the generator at the yield statement (line 196), the code after yield never executes. This leaves the span unfinished and corrupts the scope because __exit__ restores the old span. Additionally, passing (None, None, None) to __exit__ prevents the span from being marked with INTERNAL_ERROR status when an exception occurs.
Duration: 1m 52s · Tokens: 385.6k in / 5.0k out · Cost: $0.42
Annotations
Check warning on line 204 in sentry_sdk/integrations/strawberry.py
github-actions / warden: find-bugs
Span context manager not properly closed on exception - span leaks and scope corruption
The new code calls `self.graphql_span.__enter__()` at line 189 and `self.graphql_span.__exit__(None, None, None)` at line 204, but if an exception is thrown into the generator at the `yield` statement (line 196), the code after `yield` never executes. This leaves the span unfinished and corrupts the scope because `__exit__` restores the old span. Additionally, passing `(None, None, None)` to `__exit__` prevents the span from being marked with `INTERNAL_ERROR` status when an exception occurs.