Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions sentry_sdk/integrations/graphene.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,15 @@
},
)

scope = sentry_sdk.get_current_scope()
if scope.span:
_graphql_span = scope.span.start_child(op=op, name=operation_name)
else:
_graphql_span = sentry_sdk.start_span(op=op, name=operation_name)
_graphql_span = sentry_sdk.start_span(op=op, name=operation_name)

_graphql_span.set_data("graphql.document", source)
_graphql_span.set_data("graphql.operation.name", operation_name)
_graphql_span.set_data("graphql.operation.type", operation_type)

_graphql_span.__enter__()

try:
yield
finally:
_graphql_span.finish()
_graphql_span.__exit__(None, None, None)

Check warning on line 155 in sentry_sdk/integrations/graphene.py

View workflow job for this annotation

GitHub Actions / warden: find-bugs

Span exit ignores exception info, preventing error status from being set

The `__exit__(None, None, None)` call in the `finally` block always passes `None` for the exception arguments, even when an exception occurs during the `yield`. The `Span.__exit__` method (lines 396-406 in `tracing.py`) checks if `value is not None` to set `INTERNAL_ERROR` status on the span. Since `value` is always `None`, GraphQL errors will not be reflected in the span's status.

Check warning on line 155 in sentry_sdk/integrations/graphene.py

View check run for this annotation

@sentry/warden / warden: code-review

Span error status never set when exceptions occur

The code calls `_graphql_span.__exit__(None, None, None)` unconditionally in the finally block, which prevents exceptions from being recorded on the span. The `Span.__exit__` method checks `if value is not None` to set `SPANSTATUS.INTERNAL_ERROR`, but since `None` is always passed for the exception value, any exceptions raised during GraphQL execution will result in spans without proper error status. This should use `sys.exc_info()` to pass actual exception information.

Check warning on line 155 in sentry_sdk/integrations/graphene.py

View check run for this annotation

@sentry/warden / warden: find-bugs

Span error status not set when GraphQL operation raises exception

The `__exit__(None, None, None)` call always passes None for exception info regardless of whether an exception occurred during the GraphQL operation. The Span's `__exit__` method checks `if value is not None and should_be_treated_as_error(ty, value)` to set `SPANSTATUS.INTERNAL_ERROR`, but since value is always None, exceptions during GraphQL operations will not mark the span as errored. This causes incorrect telemetry where failed operations appear successful.
Loading