redis/redis-py · error · IncorrectPolicyType
Incorrect request policy type: {policy_type}
Error message
Incorrect request policy type: {policy_type} What it means
Raised inside CommandsParser.get_command_policies() when the policy string parsed out of a command's 'tips' field has a request_policy:<value> whose <value> does not match any RequestPolicy enum member (e.g. 'request_policy:random'). The except ValueError re-raises as IncorrectPolicyType, a plain Exception subclass. This indicates an unknown routing hint in the server's COMMAND tips or a stale enum table in the client.
Source
Thrown at redis/_parsers/commands.py:297
command_name: The command name to associate with found policies
"""
if isinstance(data, (str, bytes)):
# Decode bytes to string if needed
policy = str_if_bytes(data.decode())
# Check if this is a policy string
if policy.startswith("request_policy") or policy.startswith(
"response_policy"
):
if policy.startswith("request_policy"):
policy_type = policy.split(":")[1]
try:
command_with_policies[module_name][
command_name
].request_policy = RequestPolicy(policy_type)
except ValueError:
raise IncorrectPolicyType(
f"Incorrect request policy type: {policy_type}"
)
if policy.startswith("response_policy"):
policy_type = policy.split(":")[1]
try:
command_with_policies[module_name][
command_name
].response_policy = ResponsePolicy(policy_type)
except ValueError:
raise IncorrectPolicyType(
f"Incorrect response policy type: {policy_type}"
)
elif isinstance(data, list):
# For lists, recursively process each element
for item in data:View on GitHub (pinned to da03cdc7e8)
Solutions
- Upgrade redis-py to a version whose RequestPolicy enum includes the policy your server advertises.
- Check the offending tip with 'redis-cli COMMAND INFO <cmd>' and look at the tips field.
- If running a custom module, normalize its request_policy tip to one of the supported enum values.
- Pin the module/Redis version to one known-compatible with your redis-py release.
Example fix
// before rc = RedisCluster(...) rc.commands_parser.get_command_policies() # IncorrectPolicyType // after # upgrade redis-py, or on the server side ensure tips only contain # supported values: all_nodes, all_shards, all_replicas, multi_shard, # special, default_keyless, default_keyed, default_node
Defensive patterns
Strategy: validation
Validate before calling
# Sanity-check tip values against the enum before policy computation
from redis._parsers.commands import RequestPolicy
SUPPORTED = {p.value for p in RequestPolicy}
def tips_ok(cmd_info):
for tip in (cmd_info.get("tips") or []):
if isinstance(tip, (bytes, str)) and b"request_policy:" in (tip.encode() if isinstance(tip, str) else tip):
val = (tip.decode() if isinstance(tip, bytes) else tip).split(":")[1]
if val not in SUPPORTED:
return False, val
return True, None Try / catch
try:
policies = rc.commands_parser.get_command_policies()
except redis.exceptions.IncorrectPolicyType as e:
# unsupported request_policy value; upgrade client or patch module tips
raise Prevention
- Keep redis-py version aligned with your Redis/module version.
- Inspect COMMAND INFO tips before relying on custom routing policies.
- Patch custom modules to emit only supported request_policy strings.
- Pin Redis/module to a version compatible with your redis-py.
When it happens
Trigger: Connecting to a Redis version or module that advertises a request_policy tip value the installed redis-py does not know; manually injecting custom tips; running a custom Redis fork that emits non-standard policy strings.
Common situations: Newer Redis / module version than redis-py supports; mixed-version cluster where one node advertises a policy string the client enum lacks; pre-release or experimental module.
Related errors
- Incorrect response policy type: {policy_type}
- {cmd_name.upper()} command doesn't exist in Redis commands
- Subcommand {subcommand_name} not found in command {command_n
- Command {command_name} not found in commands
- Cannot identify slot number for command: {args[0]},it cannot
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/ccf0e7be2956a654.json.
Report an issue: GitHub.