Skip to content

ref(strawberry): Simplify span creation #7707

ref(strawberry): Simplify span creation

ref(strawberry): Simplify span creation #7707

Triggered via pull request March 12, 2026 12:02
Status Success
Total duration 20s
Artifacts

secret-scan.yml Required

on: pull_request
Secret Scan
15s
Secret Scan
Fit to window
Zoom out
Zoom in

Annotations

2 warnings
Span.__exit__ always called with None arguments, preventing error status on exceptions: sentry_sdk/integrations/strawberry.py#L204
The `Span.__exit__` method checks if `value is not None` to set `SPANSTATUS.INTERNAL_ERROR` on the span when an exception occurs. By always calling `self.graphql_span.__exit__(None, None, None)`, exceptions that occur during GraphQL operations won't mark the span as errored. This means error tracking for GraphQL operations loses exception context that the Span class is designed to capture.
Span context manager not properly cleaned up when exception occurs at yield: sentry_sdk/integrations/strawberry.py#L189
The `__enter__()` call at line 189 sets `scope.span = self.graphql_span` and stores the previous span for restoration. However, if an exception is thrown at the `yield` point (line 196), the code after yield including `__exit__()` (line 204) will not execute. This leaves the scope in a corrupted state where `scope.span` still points to the graphql_span, and the span is never finished. The old code used `finish()` which also wouldn't run on exception, but it didn't call `__enter__()` to modify scope, so no scope corruption occurred.