{"record":{"id":"787ce6da5c839412","repo":"redis/jedis","slug":"command-with-request-policy-cannot-be-executed","errorCode":null,"errorMessage":"Command '' with  request policy cannot be executed in pipeline mode because it cannot be routed to a single slot. This command has no keys to determine routing. Use non-pipeline cluster client for this command.","messagePattern":"Command '' with  request policy cannot be executed in pipeline mode because it cannot be routed to a single slot\\. This command has no keys to determine routing\\. Use non-pipeline cluster client for this command\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/MultiNodePipelineBase.java","lineNumber":236,"sourceCode":"    CommandFlagsRegistry.RequestPolicy policy =\n        commandFlagsRegistry.getRequestPolicy(args);\n\n    // For multi-node policies, check if the command can be routed to a single slot\n    switch (policy) {\n      case ALL_SHARDS:\n      case MULTI_SHARD:\n      case ALL_NODES:\n      case SPECIAL:\n        // If the command has keys that route to a single slot, allow it\n        Set<Integer> slots = args.getKeyHashSlots();\n        if (slots.size() == 1) {\n          // Command can be routed to a single slot - allow it\n          return;\n        }\n\n        // Command cannot be routed to a single slot - reject it\n        String policyName = policy.name();\n        throw new UnsupportedOperationException(\n            \"Command '\" + args.getCommand() + \"' with \" + policyName + \" request policy \"\n                + \"cannot be executed in pipeline mode because it cannot be routed to a single slot. \"\n                + (slots.isEmpty()\n                    ? \"This command has no keys to determine routing. \"\n                    : \"This command's keys map to multiple slots (\" + slots.size() + \" slots). \")\n                + \"Use non-pipeline cluster client for this command.\");\n\n      case DEFAULT:\n      default:\n        // DEFAULT policy and unknown policies - allow standard command execution\n        // Routes to single node based on key hash\n        break;\n    }\n  }\n\n  @Deprecated\n  public Response<Long> waitReplicas(int replicas, long timeout) {\n    return appendCommand(commandObjects.waitReplicas(replicas, timeout));","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java#L218-L254","documentation":"Cluster pipelines (MultiNodePipelineBase) can only execute commands whose keys map to a single hash slot, because each command is sent to one node. validatePipelineCommand rejects commands with a request policy whose keys are absent or spread across multiple slots by throwing UnsupportedOperationException.","triggerScenarios":"Appending to a cluster pipeline a command with no keys (e.g. PING, INFO, RANDOMKEY) or with keys hashing to multiple slots (e.g. MSET with keys on different slots) — including unkeyed custom/module commands.","commonSituations":"Migrating a standalone Jedis pipeline to a cluster pipeline; using commands without keys in pipelined mode; empty CommandObject argument lists.","solutions":["Execute the command directly on RedisClusterClient (non-pipeline) instead of the pipeline.","For multi-key commands, hash-tag the keys (e.g. {user1}:a, {user1}:b) so they map to one slot.","Remove keyless commands from the pipeline and batch them separately.","For FLUSH-style broad commands, iterate nodes or use dedicated per-node APIs."],"exampleFix":"// before\ntry (Pipeline p = clusterClient.pipelined()) {\n  p.set(\"a\", \"1\");\n  p.mset(\"b\", \"2\", \"c\", \"3\"); // keys map to multiple slots -> throws\n}\n\n// after\ntry (Pipeline p = clusterClient.pipelined()) {\n  p.set(\"{h1}a\", \"1\");\n  p.mset(\"{h1}b\", \"2\", \"{h1}c\", \"3\"); // same hash tag, single slot\n}","handlingStrategy":"fallback","validationCode":"// pre-flight: verify all keys of the command share one slot\nString tag = key.contains(\"{\") ? key.substring(key.indexOf('{') + 1, key.indexOf('}')) : key;\nint slot = JedisClusterHashSlotUtil.getHashSlot(SafeEncoder.encode(\"{\" + tag + \"}\"));\n// only append to pipeline if every key hashes to the same slot","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.appendCommand(commandObject);\n} catch (UnsupportedOperationException e) {\n  // execute outside the pipeline instead\n  clusterClient.sendCommand(commandObject);\n}","preventionTips":["Use hash tags ({tag}) on related keys to keep them in one slot.","Keep keyless commands (PING, INFO) out of cluster pipelines.","Wrap pipeline building so unsupported commands fall back to direct execution.","Review the command's request policy before adding module commands to pipelines."],"tags":["cluster","pipeline","unsupported-operation","hash-slot-routing"],"backgroundTag":"unsupported-operation","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}