{"id":"a9a15882edff0189","repo":"go-redis/redis","slug":"routing-unknown-response-policy-q","errorCode":null,"errorMessage":"routing: unknown response_policy %q","messagePattern":"routing: unknown response_policy %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/routing/policy.go","lineNumber":125,"sourceCode":"\t\treturn RespDefaultHashSlot, nil\n\tcase \"all_succeeded\":\n\t\treturn RespAllSucceeded, nil\n\tcase \"one_succeeded\":\n\t\treturn RespOneSucceeded, nil\n\tcase \"agg_sum\":\n\t\treturn RespAggSum, nil\n\tcase \"agg_min\":\n\t\treturn RespAggMin, nil\n\tcase \"agg_max\":\n\t\treturn RespAggMax, nil\n\tcase \"agg_logical_and\":\n\t\treturn RespAggLogicalAnd, nil\n\tcase \"agg_logical_or\":\n\t\treturn RespAggLogicalOr, nil\n\tcase \"special\":\n\t\treturn RespSpecial, nil\n\tdefault:\n\t\treturn RespDefaultKeyless, fmt.Errorf(\"routing: unknown response_policy %q\", raw)\n\t}\n}\n\ntype CommandPolicy struct {\n\tRequest  RequestPolicy\n\tResponse ResponsePolicy\n\t// Tips that are not request_policy or response_policy\n\t// e.g nondeterministic_output, nondeterministic_output_order.\n\tTips map[string]string\n}\n\nfunc (p *CommandPolicy) CanBeUsedInPipeline() bool {\n\treturn p.Request != ReqAllNodes && p.Request != ReqAllShards && p.Request != ReqMultiShard\n}\n\nfunc (p *CommandPolicy) IsReadOnly() bool {\n\t_, readOnly := p.Tips[ReadOnlyCMD]\n\treturn readOnly","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/routing/policy.go#L107-L143","documentation":"Returned by routing.ParseResponsePolicy when a response_policy string does not match any known value (default(keyless), default(hashslot), all_succeeded, one_succeeded, agg_sum, agg_min, agg_max, agg_logical_and, agg_logical_or, special). The parser is case-insensitive but unforgiving of typos or made-up names. On failure it falls back to RespDefaultKeyless and returns this error so the caller can decide whether to reject the policy definition.","triggerScenarios":"Calling routing.ParseResponsePolicy with a string from a command-rules/policy JSON document whose response_policy field holds a typo (e.g. \"all_succeed\", \"agg-sum\", \"ALL_SUCCEEDED\" is fine but \"aggregate_sum\" is not). Any code path that loads external command-policy definitions and forwards their response_policy field to this parser.","commonSituations":"Custom command-policy JSON shipped out-of-band (e.g. overriding routing for a module command), a version mismatch where a newer policy name is fed to an older library build that does not know it, or hand-edited policy files with underscore/hyphen mistakes.","solutions":["Check the offending value against the accepted list in policy.go:103-123 and correct the typo (use underscores, exact names).","If you are feeding a policy name from a newer go-redis/Redis spec, upgrade the library so the parser recognises it.","Treat the error as non-fatal: ParseResponsePolicy already falls back to RespDefaultKeyless, so you can log and continue if the default is acceptable."],"exampleFix":"// before\np, err := routing.ParseResponsePolicy(\"all-succeeded\")\n// after\np, err := routing.ParseResponsePolicy(\"all_succeeded\")","handlingStrategy":"validation","validationCode":"var knownResponsePolicies = map[string]bool{\n    \"default(keyless)\": true, \"default(hashslot)\": true,\n    \"all_succeeded\": true, \"one_succeeded\": true,\n    \"agg_sum\": true, \"agg_min\": true, \"agg_max\": true,\n    \"agg_logical_and\": true, \"agg_logical_or\": true,\n    \"special\": true,\n}\nfunc validResponsePolicy(s string) bool { return knownResponsePolicies[strings.ToLower(s)] }","typeGuard":"func isKnownResponsePolicy(s string) bool { _, err := routing.ParseResponsePolicy(s); return err == nil }","tryCatchPattern":null,"preventionTips":["Source response_policy values from the routing constants' String() output rather than hand-typing them.","Validate policy JSON against the accepted set at load time.","Keep the command-policy file version-aligned with the go-redis version in use."],"tags":["routing","config","validation"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}