feat: instrument RedisCluster and ClusterPipeline for record/replay#91
feat: instrument RedisCluster and ClusterPipeline for record/replay#91sohankshirsagar merged 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ec0858f. Configure here.
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="drift/instrumentation/redis/instrumentation.py">
<violation number="1" location="drift/instrumentation/redis/instrumentation.py:1125">
P2: Avoid coercing integer-valued floats to int during replay deserialization; it changes response types and can make replay behavior differ from recorded Redis responses.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Generated 30 tests - 30 passedTip New to Tusk Unit Tests? Learn more here. Test Summary
ResultsTusk's tests are all passing and cover the critical paths for Redis Cluster instrumentation. The test suite validates that View check history
Was Tusk helpful? Give feedback by reacting with 👍 or 👎 |



Summary
redis.cluster.RedisCluster.execute_commandis a completely separate method fromredis.Redis.execute_commandand does not inherit or delegate to it. This means any Redis command routed through the cluster client bypassed the SDK's record/replay interception entirely, causingPermissionErrorcrashes during replay when the cluster client attempted real TCP connections to production node addresses.This change patches
RedisCluster.execute_commandandClusterPipeline.execute(both sync and async variants) so that cluster-routed commands are properly intercepted during record and replayed from mocks.Changes
redis.cluster.RedisCluster.execute_command(sync) to route through_traced_execute_command, matching the existingredis.Redisinstrumentation patternredis.cluster.ClusterPipeline.execute(sync) with a dedicated_traced_cluster_pipeline_executethat snapshots the command queue before execution (ClusterPipeline resets the queue in itsfinallyblock)redis.asyncio.cluster.RedisCluster.execute_command(async) to route through_traced_async_execute_commandredis.asyncio.cluster.ClusterPipeline.execute(async) with_traced_async_cluster_pipeline_execute_get_pipeline_commandsto handle ClusterPipeline's different command storage:_execution_strategy._command_queue(sync) and_command_queue(async)/test/cluster-set-get,/test/cluster-incr,/test/cluster-pipelineexercisingRedisCluster.execute_commandandClusterPipeline.execute