{"record":{"id":"860ade2484c2cfc4","repo":"redis/redis-py","slug":"no-targets-were-found-to-execute-cmd-args-comman","errorCode":null,"errorMessage":"No targets were found to execute {cmd.args} command on","messagePattern":"No targets were found to execute (.+?) command on","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/asyncio/cluster.py","lineNumber":2940,"sourceCode":"                                response_policy=ResponsePolicy.DEFAULT_KEYED,\n                            )\n                    else:\n                        if command_flag in client._command_flags_mapping:\n                            command_policies = CommandPolicies(\n                                request_policy=client._command_flags_mapping[\n                                    command_flag\n                                ]\n                            )\n                        else:\n                            command_policies = CommandPolicies()\n\n                target_nodes = await client._determine_nodes(\n                    *cmd.args,\n                    request_policy=command_policies.request_policy,\n                    node_flag=passed_targets,\n                )\n                if not target_nodes:\n                    raise RedisClusterException(\n                        f\"No targets were found to execute {cmd.args} command on\"\n                    )\n            cmd.command_policies = command_policies\n            if len(target_nodes) > 1:\n                raise RedisClusterException(f\"Too many targets for command {cmd.args}\")\n            node = target_nodes[0]\n            if node.name not in nodes:\n                nodes[node.name] = (node, [])\n            nodes[node.name][1].append(cmd)\n\n        # Start timing for observability\n        start_time = time.monotonic()\n\n        errors = await asyncio.gather(\n            *(\n                asyncio.create_task(node[0].execute_pipeline(node[1]))\n                for node in nodes.values()\n            )","sourceCodeStart":2922,"sourceCodeEnd":2958,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/cluster.py#L2922-L2958","documentation":"Pipeline-side counterpart of error 65, raised in ClusterPipeline._execute() when _determine_nodes() returns an empty list for a queued command. The pipeline groups commands by target node before sending, so a command that resolves to zero nodes cannot be placed anywhere and aborts the whole pipeline execution.","triggerScenarios":"Queuing a command on a cluster pipeline whose policy resolves to an empty node set, e.g. a replica-routed command when no replicas are cached, or any command before the cluster cache is populated (initialize() not yet run / failed).","commonSituations":"Building a pipeline immediately after constructing RedisCluster without awaiting initialize(); cluster mid-failover with an empty primaries/replicas cache; read_from_replicas with no replicas deployed.","solutions":["Await rc.initialize() before building the pipeline so the slots/node cache is populated.","Set explicit target_nodes= on the queued command to bypass key/policy resolution.","Confirm the target node group is non-empty (rc.get_primaries() / get_replicas()) before pipelining against it.","Retry the pipeline after a topology refresh if the cache was transiently empty."],"exampleFix":"// before\npipe = rc.pipeline()\npipe.execute_command('GET', 'x', target_nodes=rc.REPLICAS)  # no replicas\nawait pipe.execute()\n\n// after\nawait rc.initialize()\npipe = rc.pipeline()\npipe.get('x')\nawait pipe.execute()","handlingStrategy":"validation","validationCode":"async def safe_pipeline(rc):\n    await rc.initialize()\n    if not rc.get_primaries():\n        raise RuntimeError('cluster has no primaries; cannot pipeline')\n    return rc.pipeline()","typeGuard":"null","tryCatchPattern":"from redis.exceptions import RedisClusterException\nfor _ in range(3):\n    try:\n        pipe = rc.pipeline()\n        # ...queue commands...\n        return await pipe.execute()\n    except RedisClusterException as e:\n        if 'No targets were found' not in str(e):\n            raise\n        await rc.initialize()","preventionTips":["Await rc.initialize() before constructing a pipeline.","Set explicit target_nodes on queued commands that may resolve to empty node groups.","Confirm primaries/replicas exist before pipelining against those groups."],"tags":["cluster","pipeline","routing","topology"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}