redis/redis-py · error · IncorrectPolicyType

Incorrect request policy type

Error message

Incorrect request policy type: {policy_type}

What it means

Raised by the sync CommandsParser.get_command_policies().extract_policies() (redis/_parsers/commands.py:297) when a 'request_policy:<value>' tip string from the server's COMMAND output cannot be mapped to a RequestPolicy enum member (RequestPolicy(policy_type) raises ValueError). It surfaces as IncorrectPolicyType, meaning the server advertised a request-routing policy the client does not recognize.

Solutions

  1. Upgrade redis-py to a version whose RequestPolicy enum includes the new policy value.
  2. Align/downgrade the Redis server or module to a version whose tips this client understands.
  3. If from a custom module, fix the module's tip to use a standard RequestPolicy value.
  4. Report the unrecognized policy string to redis-py maintainers with the COMMAND output.
Defensive patterns

Strategy: try-catch

Validate before calling

# Verify the server-advertised request_policy tip is a known enum value
from redis._parsers.commands import RequestPolicy
valid = {m.value for m in RequestPolicy}
if policy_value not in valid:
    raise ValueError(f"unsupported request_policy: {policy_value}; upgrade redis-py")

Try / catch

from redis.exceptions import IncorrectPolicyType
try:
    policies = parser.get_command_policies()
except IncorrectPolicyType as e:
    # version skew: newer server advertised an unknown request_policy
    # -> upgrade redis-py or align server version
    ...

Prevention

When it happens

Trigger: A Redis server or module publishes a command tip like 'request_policy:<x>' where <x> is not one of the RequestPolicy values (all_nodes, all_shards, all_replicas, multi_shard, special, default_keyless, default_keyed, default_node). Typically a newer server than the client library.

Common situations: Version skew — newer Redis or a new module advertising a policy this redis-py release doesn't know; a custom module declaring a non-standard request_policy tip.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/ccf0e7be2956a654. Report an issue: GitHub.

Appendix: 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 6a6b581b48)