{"id":"695ccd8c022a029c","repo":"redis/node-redis","slug":"unknown-response-policy-responsepolicy","errorCode":null,"errorMessage":"Unknown response policy ${responsePolicy}","messagePattern":"Unknown response policy (.+?)","errorType":"validation","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/bb5beb56578573910e2ee8f39681edc214c41398/packages/client/lib/cluster/index.ts#L559-L595","documentation":"Thrown from RedisCluster._executeWithPolicies (cluster/index.ts:577) when the resolved response policy string has no entry in RESPONSE_REDUCERS. The reducer table covers one_succeeded, all_succeeded, agg_logical_and/or/min/max/sum, special, default-keyless/keyed; an unknown response policy cannot be aggregated and the command is aborted before any node is contacted (to avoid orphaned in-flight replies).","triggerScenarios":"A command/module whose resolved response policy is a string outside the reducer table — e.g. a server-emitted response_policy tip this client version does not implement, or a malformed custom command registration.","commonSituations":"Server/client version skew introducing a new aggregation tip; custom commands with non-standard response policies; module commands returning unsupported tips.","solutions":["Upgrade the client to a version whose reducer table includes the policy.","For custom commands, leave the response policy unset so the default applies.","Report the interpolated policy string (in the error message) along with the command and server version."],"exampleFix":"// no direct user API; mitigation is version alignment:\n// before: module command resolves to response policy 'agg_avg' (unsupported)\n// after: upgrade client, or invoke the command on a single node via getSlotMaster to bypass fan-out\nconst node = await cluster.getSlotMaster('k');\nawait node.sendCommand(['MYMODULECMD', 'k']);","handlingStrategy":"fallback","validationCode":null,"typeGuard":"function isUnknownResponsePolicy(e: unknown): boolean {\n  return e instanceof Error && /Unknown response policy/i.test(e.message);\n}","tryCatchPattern":"try { await cluster.sendCommand(cmd); }\ncatch (e) {\n  if (isUnknownResponsePolicy(e)) {\n    const node = await cluster.getSlotMaster(key);\n    return node.sendCommand(cmd); // bypass fan-out aggregation\n  }\n  throw e;\n}","preventionTips":["Upgrade the client when adopting new server-side aggregation tips.","Leave response policy unset for custom commands to use defaults.","Report the interpolated policy string with the command and server version."],"tags":["cluster","command-metadata","internal","routing"],"analyzedSha":"bb5beb56578573910e2ee8f39681edc214c41398","analyzedAt":"2026-08-03T19:09:15.686Z","schemaVersion":2}