Skip to content

.

9c2ea89
Select commit
Loading
Failed to load commit list.
Merged

fix: Introduce _get_current_streamed_span() to keep types backwards compatible #6177

.
9c2ea89
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Apr 30, 2026 in 1m 28s

1 issue

find-bugs: Found 1 issue (1 high)

High

NoOpStreamedSpan guard is dead code in get_traceparent — calls _to_traceparent on no-op spans - `sentry_sdk/scope.py:587-589`

The guard not isinstance(self.span, NoOpStreamedSpan) mixes two mutually-exclusive properties. The span property returns self._span only when it's a Span (line 884), while streamed_span returns self._span only when it's a StreamedSpan (line 901). When self.streamed_span is not None, self._span is a StreamedSpan, so self.span returns None, and isinstance(None, NoOpStreamedSpan) is always False. The guard never trips, so _to_traceparent() will be invoked on a NoOpStreamedSpan (which is a subclass of StreamedSpan, traces.py:556), producing incorrect traceparent headers in no-op tracing scenarios.

Also found at:

  • sentry_sdk/scope.py:605-607

Duration: 1m 26s · Tokens: 696.6k in / 11.3k out · Cost: $3.14 (+merge: $0.00)

Annotations

Check failure on line 589 in sentry_sdk/scope.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

NoOpStreamedSpan guard is dead code in get_traceparent — calls _to_traceparent on no-op spans

The guard `not isinstance(self.span, NoOpStreamedSpan)` mixes two mutually-exclusive properties. The `span` property returns `self._span` only when it's a `Span` (line 884), while `streamed_span` returns `self._span` only when it's a `StreamedSpan` (line 901). When `self.streamed_span is not None`, `self._span` is a `StreamedSpan`, so `self.span` returns `None`, and `isinstance(None, NoOpStreamedSpan)` is always `False`. The guard never trips, so `_to_traceparent()` will be invoked on a `NoOpStreamedSpan` (which is a subclass of `StreamedSpan`, traces.py:556), producing incorrect traceparent headers in no-op tracing scenarios.

Check failure on line 607 in sentry_sdk/scope.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

[8PJ-Q2W] NoOpStreamedSpan guard is dead code in get_traceparent — calls _to_traceparent on no-op spans (additional location)

The guard `not isinstance(self.span, NoOpStreamedSpan)` mixes two mutually-exclusive properties. The `span` property returns `self._span` only when it's a `Span` (line 884), while `streamed_span` returns `self._span` only when it's a `StreamedSpan` (line 901). When `self.streamed_span is not None`, `self._span` is a `StreamedSpan`, so `self.span` returns `None`, and `isinstance(None, NoOpStreamedSpan)` is always `False`. The guard never trips, so `_to_traceparent()` will be invoked on a `NoOpStreamedSpan` (which is a subclass of `StreamedSpan`, traces.py:556), producing incorrect traceparent headers in no-op tracing scenarios.