Skip to content

unify async and sync

780bcd1
Select commit
Loading
Failed to load commit list.
Merged

feat(redis): Support streaming spans #6083

unify async and sync
780bcd1
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Apr 23, 2026 in 10m 28s

5 issues

Medium

Spans not closed when Redis command raises exception - `sentry_sdk/integrations/redis/_sync_common.py:151-158`

In sentry_patched_execute_command, spans are entered with __enter__() and exited with __exit__() manually, but if old_execute_command() raises an exception, __exit__() is never called for either db_span or cache_span. This leaves spans unclosed when Redis commands fail, which causes resource leaks and incorrect span hierarchies. The patch_redis_pipeline function uses the with span: pattern correctly, but this function does not.

Test parameters `expected_first_ten` and `send_default_pii` not verified in streaming branch - `tests/integrations/redis/asyncio/test_redis_asyncio.py:66-88`

In the span_streaming=True branch (lines 66-88), the test parameters expected_first_ten and send_default_pii are passed to the test but never verified. The static path verifies these via redis.commands.first_ten assertions. This means PII filtering behavior is not tested in the streaming code path, reducing test coverage for a security-sensitive feature.

Also found at:

  • tests/integrations/redis/cluster/test_redis_cluster.py:152-153
Test assertion checks wrong span index for cache.hit property - `tests/integrations/redis/test_redis_cache_module_async.py:293`

On line 293, the assertion assert "cache.hit" not in spans[1]["data"] checks spans[1] (the db.redis span from line 286), but should check spans[2] (the cache.put span being validated in the surrounding assertions on lines 288-294). This causes the test to validate the wrong span, making it less reliable for catching regressions in the cache.put functionality.

Also found at:

  • tests/integrations/redis/test_redis_cache_module.py:330
Spans not closed when Redis command raises an exception - `sentry_sdk/integrations/redis/_async_common.py:145-158`

In _sentry_execute_command, spans are manually entered via __enter__() but if old_execute_command raises an exception, neither db_span.__exit__() nor cache_span.__exit__() are called. This leaves spans in an incomplete state (never finished) and leaks span context on the scope. The spans should be wrapped in try/finally to ensure proper cleanup.

Also found at:

  • sentry_sdk/integrations/redis/_sync_common.py:151-158
Test asserts cache.hit absence on wrong span index - `tests/integrations/redis/test_redis_cache_module.py:330`

Line 330 checks spans[1]["data"] for the absence of cache.hit, but the surrounding assertions (lines 325-329 and 331) all operate on spans[2] which is the cache.put span. spans[1] is a db.redis span (as confirmed by line 323). This test bug means the assertion passes by accident since db.redis spans don't have cache.hit, rather than verifying the intended behavior that cache.put spans should not have cache.hit.

Also found at:

  • tests/integrations/redis/test_redis_cache_module_async.py:293
4 skills analyzed
Skill Findings Duration Cost
code-review 3 7m 51s $3.91
find-bugs 2 5m 45s $7.65
skill-scanner 0 9m 1s $1.68
security-review 0 10m 19s $1.71

Duration: 32m 56s · Tokens: 10.0M in / 104.7k out · Cost: $14.99 (+extraction: $0.02, +merge: $0.00, +fix_gate: $0.01, +dedup: $0.01)