Skip to content

Fix async ClusterPipeline missing nodes_manager and set_response_callback required by JSON module#3989

Merged
petyaslavova merged 1 commit intomasterfrom
ps_fix_json_module_usage_from_cluster_pipeline
Mar 6, 2026
Merged

Fix async ClusterPipeline missing nodes_manager and set_response_callback required by JSON module#3989
petyaslavova merged 1 commit intomasterfrom
ps_fix_json_module_usage_from_cluster_pipeline

Conversation

@petyaslavova
Copy link
Copy Markdown
Collaborator

@petyaslavova petyaslavova commented Mar 5, 2026

Summary

Fixes #3936 where calling .json() on an async ClusterPipeline raised AttributeError: 'ClusterPipeline' object has no attribute 'nodes_manager'.

Problem

The Redis JSON module requires access to nodes_manager (for protocol version checking) and set_response_callback (for registering command decoders) during initialization. The async ClusterPipeline uses a composition pattern—holding a reference to cluster_client rather than inheriting from RedisCluster like the sync implementation—so these members weren't automatically available.

Solution

  • Added nodes_manager property that delegates to self.cluster_client.nodes_manager
  • Added set_response_callback() method that delegates to self.cluster_client.set_response_callback()

Testing

  • Unit tests verify the property and method correctly delegate to the cluster client
  • Test confirms pipeline.json() can now be called without errors on both standalone and cluster pipelines

Notes

The sync ClusterPipeline is not affected since it inherits directly from RedisCluster.


Note

Low Risk
Low risk: adds simple delegation accessors on ClusterPipeline and corresponding tests, mainly to unblock pipeline.json() without changing command execution behavior.

Overview
Fixes an AttributeError when calling pipeline.json() on async cluster pipelines by exposing ClusterPipeline.nodes_manager and ClusterPipeline.set_response_callback() as delegations to the underlying RedisCluster client.

Adds async tests verifying these delegations and that pipeline.json() initializes successfully and registers JSON.* response callbacks on the cluster client.

Written by Cursor Bugbot for commit e689342. This will update automatically on new commits. Configure here.

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Mar 5, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an async Redis Cluster pipeline compatibility gap needed by the RedisJSON module, where calling pipeline.json() on redis.asyncio.cluster.ClusterPipeline raised AttributeError due to missing nodes_manager and set_response_callback.

Changes:

  • Add ClusterPipeline.nodes_manager property delegating to the underlying RedisCluster client.
  • Add ClusterPipeline.set_response_callback() delegating to the underlying RedisCluster client.
  • Add async tests covering the delegation behavior and ensuring pipeline.json() initializes successfully (standalone + cluster).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
redis/asyncio/cluster.py Exposes nodes_manager + set_response_callback on async ClusterPipeline via delegation to the composed cluster client.
tests/test_asyncio/test_cluster.py Adds unit tests asserting the new delegation property/method behave as expected for cluster pipelines.
tests/test_asyncio/test_pipeline.py Adds a regression test verifying pipeline.json() no longer raises and registers JSON response callbacks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@petyaslavova petyaslavova merged commit 75bf91b into master Mar 6, 2026
68 checks passed
@petyaslavova petyaslavova deleted the ps_fix_json_module_usage_from_cluster_pipeline branch March 6, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

redis.asyncio.cluster.ClusterPipeline does not have set_response_callback and nodes_manager

3 participants