Skip to content

limit api to traces.py and mark private

11fe228
Select commit
Loading
Failed to load commit list.
Merged

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

limit api to traces.py and mark private
11fe228
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Apr 30, 2026 in 2m 33s

2 issues

Medium

streamed_span setter unconditionally overwrites self._span, can clobber an existing Span - `sentry_sdk/scope.py:917`

The new streamed_span setter assigns self._span = span without checking what is currently stored. If the scope currently holds a Span (transaction-mode) and any caller assigns scope.streamed_span = None or a StreamedSpan, the existing Span is silently destroyed. The same asymmetry exists on the span setter for an existing StreamedSpan. Because Scope.span and Scope.streamed_span are documented as type-discriminated views over the same underlying _span, callers reasonably assume that touching one will not affect the other; this assumption does not hold and can lead to lost spans/transactions when both lifecycles are mixed.

Low

Client lookup moved outside capture_internal_exceptions guard in _set_status - `sentry_sdk/integrations/celery/__init__.py:101-102`

The new code calls sentry_sdk.get_client() and has_span_streaming_enabled(client.options) outside the with capture_internal_exceptions(): block. Previously, all logic in _set_status was protected so that any internal SDK error would be swallowed. Since _set_status is invoked from _capture_exception during task error handling, an unexpected exception here (e.g., due to an uninitialized/NonRecordingClient state or a future change to has_span_streaming_enabled) would now propagate into user code rather than being captured internally, potentially masking the original task error.

4 skills analyzed
Skill Findings Duration Cost
code-review 1 1m 53s $2.80
find-bugs 1 1m 26s $3.82
skill-scanner 0 2m 27s $1.50
security-review 0 2m 2s $1.50

Duration: 7m 48s · Tokens: 2.2M in / 21.5k out · Cost: $9.62 (+extraction: $0.00, +dedup: $0.01)