Skip to content

.

032c7e2
Select commit
Loading
Failed to load commit list.
Draft

feat(redis): Support streaming spans #6083

.
032c7e2
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Apr 16, 2026 in 3m 32s

2 issues

find-bugs: Found 2 issues (2 high)

High

Missing exception handling in async Redis client causes span leak on error - `sentry_sdk/integrations/redis/_async_common.py:145-147`

In _sentry_execute_command, if old_execute_command raises an exception, the manually-entered db_span and cache_span are never exited via __exit__. The sync version properly wraps this in a try/finally block (lines 151-161 in _sync_common.py), but the async version does not. This leads to resource leaks and orphaned spans when Redis commands fail.

Also found at:

  • sentry_sdk/integrations/redis/_async_common.py:147
  • sentry_sdk/integrations/redis/_sync_common.py:158
NameError at runtime: 'Span' is not defined in isinstance check - `sentry_sdk/integrations/redis/utils.py:115-117`

The Span class is only imported under TYPE_CHECKING (line 17), but it's used in an isinstance(span, Span) check at runtime (line 115). Since TYPE_CHECKING is False at runtime, Span will not be defined, causing a NameError when _set_pipeline_data is called. This will crash Redis pipeline operations.


Duration: 3m 25s · Tokens: 1.9M in / 17.8k out · Cost: $2.82 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.00)

Annotations

Check failure on line 147 in sentry_sdk/integrations/redis/_async_common.py

See this annotation in the file changed.

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

Missing exception handling in async Redis client causes span leak on error

In `_sentry_execute_command`, if `old_execute_command` raises an exception, the manually-entered `db_span` and `cache_span` are never exited via `__exit__`. The sync version properly wraps this in a `try/finally` block (lines 151-161 in `_sync_common.py`), but the async version does not. This leads to resource leaks and orphaned spans when Redis commands fail.

Check failure on line 147 in sentry_sdk/integrations/redis/_async_common.py

See this annotation in the file changed.

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

[HSQ-4YN] Missing exception handling in async Redis client causes span leak on error (additional location)

In `_sentry_execute_command`, if `old_execute_command` raises an exception, the manually-entered `db_span` and `cache_span` are never exited via `__exit__`. The sync version properly wraps this in a `try/finally` block (lines 151-161 in `_sync_common.py`), but the async version does not. This leads to resource leaks and orphaned spans when Redis commands fail.

Check failure on line 158 in sentry_sdk/integrations/redis/_sync_common.py

See this annotation in the file changed.

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

[HSQ-4YN] Missing exception handling in async Redis client causes span leak on error (additional location)

In `_sentry_execute_command`, if `old_execute_command` raises an exception, the manually-entered `db_span` and `cache_span` are never exited via `__exit__`. The sync version properly wraps this in a `try/finally` block (lines 151-161 in `_sync_common.py`), but the async version does not. This leads to resource leaks and orphaned spans when Redis commands fail.

Check failure on line 117 in sentry_sdk/integrations/redis/utils.py

See this annotation in the file changed.

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

NameError at runtime: 'Span' is not defined in isinstance check

The `Span` class is only imported under `TYPE_CHECKING` (line 17), but it's used in an `isinstance(span, Span)` check at runtime (line 115). Since `TYPE_CHECKING` is `False` at runtime, `Span` will not be defined, causing a `NameError` when `_set_pipeline_data` is called. This will crash Redis pipeline operations.