{"record":{"id":"1a3c0902cd395aa9","repo":"redis/node-redis","slug":"cannot-split-label-multiple-key-specifications","errorCode":null,"errorMessage":"Cannot split ${label}: multiple key specifications are not supported","messagePattern":"Cannot split (.+?): multiple key specifications are not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/lib/cluster/request-response-policies/multi-shard-splitter.ts","lineNumber":56,"sourceCode":" */\nexport function splitMultiShardCommand(\n  args: ReadonlyArray<RedisArgument>,\n  keySpecs: ReadonlyArray<KeySpec> | undefined\n): Map<number, SubCommand> {\n  const label = args.length > 0 ? args[0].toString() : '<empty>';\n\n  if (!keySpecs || keySpecs.length === 0) {\n    throw new Error(`Cannot split ${label}: command has no key specification`);\n  }\n  // TODO(multi-spec): a command whose keys are interchangeable but\n  // syntactically scattered (e.g. a fixed-position key plus a keyword-tail\n  // list) could legitimately be multi_shard with several specs, and\n  // multi-region reconstruction would be deterministic. No such command\n  // exists, and specs alone cannot distinguish that shape from linked-operand\n  // specs (GEORADIUS-like) where splitting is meaningless — so refuse until a\n  // real command motivates multi-region support.\n  if (keySpecs.length > 1) {\n    throw new Error(`Cannot split ${label}: multiple key specifications are not supported`);\n  }\n\n  const { beginSearch, findKeys } = keySpecs[0];\n  if (beginSearch.type !== 'index') {\n    throw new Error(`Cannot split ${label}: unsupported begin_search type '${beginSearch.type}'`);\n  }\n\n  const start = beginSearch.index;\n  let keyRegionStart: number;\n  let keyRegionEnd: number;\n  let keyStep: number;\n  // Absolute position of the numkeys argument to rewrite per sub-command.\n  let keyNumIdx: number | undefined;\n\n  switch (findKeys.type) {\n    case 'range': {\n      // All current multi_shard range specs are \"until end of args\"; bounded\n      // ranges (lastKey >= 0) and limit can be added when a command needs them.","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/cluster/request-response-policies/multi-shard-splitter.ts#L38-L74","documentation":"Thrown by the multi-shard splitter when a command tagged multi_shard has more than one key specification. The splitter only supports a single spec because multiple specs could represent linked operands (like GEORADIUS_RO's source-key + store-key pair) where splitting is semantically meaningless — the results would be incorrect. Refusing is safer than guessing.","triggerScenarios":"A command with multiple key specs is tagged multi_shard in the metadata; a metadata regeneration or dynamic COMMAND DOCS response introduces a multi-spec command with this policy.","commonSituations":"Metadata regeneration tags a multi-spec command as multi_shard; custom command metadata override assigns multi_shard to a command with linked key operands.","solutions":["This is by design — the command should not be multi_shard if it has linked operands","Check whether the command's keys are truly interchangeable (all-same-slot semantics) or linked (cross-slot semantics)","Report the issue if a standard command that should be multi_shard triggers this"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isMultipleKeySpecs(err: unknown): boolean {\n  return err instanceof Error && err.message.includes('multiple key specifications');\n}","tryCatchPattern":"try {\n  await cluster.sendCommand(false, 'CUSTOM_CMD', ['key1', 'key2']);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('multiple key specifications')) {\n    // command has linked operands — route manually per slot\n  } else {\n    throw err;\n  }\n}","preventionTips":["Do not tag commands with linked key operands (like GEORADIUS) as multi_shard","If a command has multiple key specs, verify the keys are truly interchangeable before tagging multi_shard","Report the issue if a standard command that should be multi_shard triggers this"],"tags":["cluster","multi-shard","key-spec","metadata"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}