redis/redis-py · error · IncorrectPolicyType

Incorrect response policy type

Error message

Incorrect response policy type: {policy_type}

What it means

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

Solutions

  1. Upgrade redis-py to a release whose ResponsePolicy enum includes the advertised value.
  2. Align the server/module version with what this client supports.
  3. For a custom module, use a standard ResponsePolicy tip value.
  4. File an upstream issue with the exact tip string from COMMAND INFO.
Defensive patterns

Strategy: try-catch

Validate before calling

# Verify the server-advertised response_policy tip is a known enum value
from redis._parsers.commands import ResponsePolicy
valid = {m.value for m in ResponsePolicy}
if policy_value not in valid:
    raise ValueError(f"unsupported response_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 response_policy
    # -> upgrade redis-py or align server version
    ...

Prevention

When it happens

Trigger: A Redis server or module publishes a command tip like 'response_policy:<x>' where <x> is not among ResponsePolicy values (one_succeeded, all_succeeded, agg_logical_and, agg_logical_or, agg_min, agg_max, agg_sum, special, default_keyless, default_keyed). Usually a newer server/module than the client.

Common situations: Version skew between a newer Redis/module and an older redis-py; a custom module declaring an unsupported response_policy tip.

Related errors


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

Appendix: source

Thrown at redis/_parsers/commands.py:309

                        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:
                    extract_policies(item, module_name, command_name)

            elif isinstance(data, dict):
                # For dictionaries, recursively process each value
                for value in data.values():
                    extract_policies(value, module_name, command_name)

        for command, details in self.commands.items():
            # Check whether the command has keys
            is_keyless = self._is_keyless_command(command)

            if is_keyless:

View on GitHub (pinned to 6a6b581b48)