{"record":{"id":"695ccd8c022a029c","repo":"redis/node-redis","slug":"unknown-response-policy-responsepolicy","errorCode":null,"errorMessage":"Unknown response policy ${responsePolicy}","messagePattern":"Unknown response policy (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/lib/cluster/index.ts","lineNumber":577,"sourceCode":"    // none of them default-keyed).\n    if (\n      requestPolicy === REQUEST_POLICIES_WITH_DEFAULTS.DEFAULT_KEYED &&\n      responsePolicy === RESPONSE_POLICIES_WITH_DEFAULTS.DEFAULT_KEYED\n    ) {\n      return this._execute(parser, readonly, options, makeFn(parser));\n    }\n\n    // https://redis.io/docs/latest/develop/reference/command-tips\n    const router = REQUEST_ROUTERS[requestPolicy];\n    if (!router) {\n      throw new Error(`Unknown request policy ${requestPolicy}`);\n    }\n    // Validated before any per-node promise is dispatched — throwing after\n    // would orphan in-flight rejections (unhandled-rejection noise) and run\n    // side effects for a reply that can never be reduced.\n    const reducer = RESPONSE_REDUCERS[responsePolicy];\n    if (!reducer) {\n      throw new Error(`Unknown response policy ${responsePolicy}`);\n    }\n    // Routers are typed against the erased base cluster types (routing is\n    // below the typed command surface); bridge this instantiation's slots in.\n    const plan = await router(\n      this._slots as unknown as Parameters<typeof router>[0],\n      parser,\n      readonly,\n      policy.keySpecs\n    );\n\n    if (plan.length === 0) {\n      throw new Error(`Request policy ${requestPolicy} produced no target nodes`);\n    }\n\n    // Numeric aggregation must see raw numbers: strip the caller's type\n    // mapping from the per-node executions (a `NUMBER: String` mapping would\n    // feed strings into the numeric reducers) and re-apply it to the\n    // aggregated result below. Pass-through policies keep the mapping — their","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/cluster/index.ts#L559-L595","documentation":"Thrown in the cluster command dispatch when a command's resolved response policy is not present in the RESPONSE_REDUCERS registry. Validation happens before any per-node command is dispatched (so no orphaned in-flight requests result). An unknown response policy means the command metadata or custom command specified a reducer the cluster cannot apply to fan-out replies.","triggerScenarios":"Defining a custom command or script whose metadata sets a response value not in RESPONSE_POLICIES_WITH_DEFAULTS. A version mismatch where the command's response policy was introduced in a newer library version than installed. Invalid metadata injected for a custom multi-shard command.","commonSituations":"Custom/script commands with manually-configured response policies that are misspelled or unsupported; running a built-in command whose policy was added in a newer release; overriding command metadata with an invalid response value.","solutions":["For custom commands, use a supported response policy (ONE_SUCCEEDED, ALL_SUCCEEDED, AGG_LOGICAL_AND, AGG_LOGICAL_OR, AGG_MIN, AGG_MAX, AGG_SUM, SPECIAL, DEFAULT_KEYLESS, DEFAULT_KEYED) or omit to default.","Upgrade node-redis so the response policy table matches the command metadata in use.","Audit any code setting command metadata .response to confirm it uses a registered value.","Report with the command name and resolved responsePolicy if it fires on a built-in command."],"exampleFix":"// before (custom command metadata with bad policy)\n{ RESPONSE_POLICY: 'sum_all' /* not in registry */ }\n\n// after\n{ RESPONSE_POLICY: 'agg_sum' } // valid registry value","handlingStrategy":"validation","validationCode":"import { RESPONSE_POLICIES_WITH_DEFAULTS } from '@redis/client';\nfunction isValidResponsePolicy(p: string): boolean {\n  return Object.values(RESPONSE_POLICIES_WITH_DEFAULTS).includes(p as never);\n}\nisValidResponsePolicy(metadata.response);","typeGuard":"function isKnownResponsePolicy(p: unknown, known: readonly string[]): p is string {\n  return typeof p === 'string' && known.includes(p);\n}","tryCatchPattern":"try {\n  await cluster.executeCommand(...);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unknown response policy')) {\n    // fix command metadata to use a supported policy\n  } else throw e;\n}","preventionTips":["Use only registered response policies for custom command metadata.","Keep node-redis version aligned with the command metadata in use.","Import policy constants from the library rather than hardcoding strings."],"tags":["cluster","routing","command-policy","configuration"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}