{"id":"985a39461c0cf9ec","repo":"redis/redis-py","slug":"no-targets-were-found-to-execute-c-args-command","errorCode":null,"errorMessage":"No targets were found to execute {c.args} command on","messagePattern":"No targets were found to execute (.+?) command on","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":4291,"sourceCode":"                                    response_policy=ResponsePolicy.DEFAULT_KEYED,\n                                )\n                        else:\n                            if command_flag in self._pipe._command_flags_mapping:\n                                command_policies = CommandPolicies(\n                                    request_policy=self._pipe._command_flags_mapping[\n                                        command_flag\n                                    ]\n                                )\n                            else:\n                                command_policies = CommandPolicies()\n\n                    target_nodes = self._determine_nodes(\n                        *c.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 {c.args} command on\"\n                        )\n                c.command_policies = command_policies\n                if len(target_nodes) > 1:\n                    raise RedisClusterException(\n                        f\"Too many targets for command {c.args}\"\n                    )\n\n                node = target_nodes[0]\n                if node == self._pipe.get_default_node():\n                    is_default_node = True\n\n                # now that we know the name of the node\n                # ( it's just a string in the form of host:port )\n                # we can build a list of commands for each node.\n                node_name = node.name\n                if node_name not in nodes:\n                    redis_node = self._pipe.get_redis_connection(node)","sourceCodeStart":4273,"sourceCodeEnd":4309,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/cluster.py#L4273-L4309","documentation":"Raised in PipelineStrategy._send_cluster_commands (redis/cluster.py:4291) when _determine_nodes() returns an empty list for a queued command. The cluster pipeline requires each command to resolve to at least one node; if the command has no key, no predefined routing flag, and no explicit target_nodes, there is no node to send it to. This is a routing-resolution failure, not a network error.","triggerScenarios":"Queuing a keyless command with no target_nodes in a cluster pipeline (e.g. pipe.info(), pipe.config_get(), pipe.client_getname()) when no default node exists, or passing target_nodes=REPLICAS when the cluster currently has zero replicas. Also when an unknown/custom command has no COMMAND INFO metadata and no key.","commonSituations":"Calling administrative or keyless commands (INFO, CONFIG, CLIENT, DEBUG) through a cluster pipeline without specifying target_nodes. Cluster deployed with primaries only (no replicas) while code requests target_nodes=RedisCluster.REPLICAS. Using a custom command module whose COMMAND INFO is not loaded. Default node unavailable after a topology change.","solutions":["Pass an explicit target to the keyless command: pipe.info(target_nodes=RedisCluster.PRIMARIES) or pipe.info(target_nodes=RedisCluster.DEFAULT_NODE).","Use the non-pipeline client API for admin commands: rc.info(target_nodes=RedisCluster.PRIMARIES).","If you requested REPLICAS/ALL_NODES, verify the cluster actually has those nodes via rc.cluster_nodes() and fall back to PRIMARIES when empty.","For custom/module commands, ensure COMMAND INFO is reachable so the resolver can derive routing, or always pass target_nodes explicitly."],"exampleFix":"# before\npipe = rc.pipeline()\npipe.info()           # no key -> no resolvable target\npipe.execute()\n\n# after\npipe = rc.pipeline()\npipe.info(target_nodes=RedisCluster.PRIMARIES)\npipe.execute()","handlingStrategy":"validation","validationCode":"from redis.cluster import RedisCluster\n\ndef queue_keyless_in_pipeline(pipe, cmd, *args, target=None):\n    # keyless commands need an explicit target in a cluster pipeline\n    if target is None:\n        target = RedisCluster.PRIMARIES\n    getattr(pipe, cmd)(*args, target_nodes=target)\n    return pipe","typeGuard":null,"tryCatchPattern":"from redis.exceptions import RedisClusterException\n\ntry:\n    pipe.info()\n    pipe.execute()\nexcept RedisClusterException as e:\n    if 'No targets were found' in str(e):\n        rc.info(target_nodes=RedisCluster.PRIMARIES)  # run on client with target\n    else:\n        raise","preventionTips":["Always pass target_nodes for keyless/admin commands in a cluster pipeline.","Verify the requested node group is non-empty with rc.cluster_nodes() before relying on REPLICAS/ALL_NODES.","Prefer the non-pipeline client API for admin commands like INFO/CONFIG/CLIENT."],"tags":["cluster","pipeline","routing","keyless-command"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}