go-redis/redis · warning

routing: unknown response_policy

Error message

routing: unknown response_policy %q

What it means

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.

Solutions

  1. Check the offending value against the accepted list in policy.go:103-123 and correct the typo (use underscores, exact names).
  2. If you are feeding a policy name from a newer go-redis/Redis spec, upgrade the library so the parser recognises it.
  3. Treat the error as non-fatal: ParseResponsePolicy already falls back to RespDefaultKeyless, so you can log and continue if the default is acceptable.

Example fix

// before
p, err := routing.ParseResponsePolicy("all-succeeded")
// after
p, err := routing.ParseResponsePolicy("all_succeeded")
Defensive patterns

Strategy: validation

Validate before calling

var knownResponsePolicies = map[string]bool{
    "default(keyless)": true, "default(hashslot)": true,
    "all_succeeded": true, "one_succeeded": true,
    "agg_sum": true, "agg_min": true, "agg_max": true,
    "agg_logical_and": true, "agg_logical_or": true,
    "special": true,
}
func validResponsePolicy(s string) bool { return knownResponsePolicies[strings.ToLower(s)] }

Type guard

func isKnownResponsePolicy(s string) bool { _, err := routing.ParseResponsePolicy(s); return err == nil }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /api/errors/a9a15882edff0189. Report an issue: GitHub.

Appendix: source

Thrown at internal/routing/policy.go:125

		return RespDefaultHashSlot, nil
	case "all_succeeded":
		return RespAllSucceeded, nil
	case "one_succeeded":
		return RespOneSucceeded, nil
	case "agg_sum":
		return RespAggSum, nil
	case "agg_min":
		return RespAggMin, nil
	case "agg_max":
		return RespAggMax, nil
	case "agg_logical_and":
		return RespAggLogicalAnd, nil
	case "agg_logical_or":
		return RespAggLogicalOr, nil
	case "special":
		return RespSpecial, nil
	default:
		return RespDefaultKeyless, fmt.Errorf("routing: unknown response_policy %q", raw)
	}
}

type CommandPolicy struct {
	Request  RequestPolicy
	Response ResponsePolicy
	// Tips that are not request_policy or response_policy
	// e.g nondeterministic_output, nondeterministic_output_order.
	Tips map[string]string
}

func (p *CommandPolicy) CanBeUsedInPipeline() bool {
	return p.Request != ReqAllNodes && p.Request != ReqAllShards && p.Request != ReqMultiShard
}

func (p *CommandPolicy) IsReadOnly() bool {
	_, readOnly := p.Tips[ReadOnlyCMD]
	return readOnly

View on GitHub (pinned to 36d97525cd)