redis/redis-py · error · IncorrectPolicyType

Incorrect response policy type: {policy_type}

Error message

Incorrect response policy type: {policy_type}

What it means

Mirror of error 7 for the response side: raised when a response_policy:<value> tip does not match any ResponsePolicy enum member. Same IncorrectPolicyType exception, same code path in get_command_policies(). Indicates the server advertises an aggregation/response strategy the client does not understand.

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 da03cdc7e8)

Solutions

  1. Upgrade redis-py to a release whose ResponsePolicy enum covers the value your server advertises.
  2. Inspect tips via 'redis-cli COMMAND INFO <cmd>' and confirm the response_policy string.
  3. Pin or patch the module so its response_policy tip uses a supported value (one_succeeded, all_succeeded, agg_logical_and, agg_logical_or, agg_min, agg_max, agg_sum, special, default_keyless, default_keyed).
  4. File an issue upstream so the enum is extended for the new policy.

Example fix

// before
rc = RedisCluster(...)
rc.commands_parser.get_command_policies()  # IncorrectPolicyType: response

// after
# upgrade redis-py; or on module side restrict tips to supported values
Defensive patterns

Strategy: validation

Validate before calling

from redis._parsers.commands import ResponsePolicy
SUPPORTED = {p.value for p in ResponsePolicy}
def response_tip_supported(tip):
    if isinstance(tip, (bytes, str)) and "response_policy:" in (tip.decode() if isinstance(tip, bytes) else tip):
        val = (tip.decode() if isinstance(tip, bytes) else tip).split(":")[1]
        return val in SUPPORTED
    return True

Try / catch

try:
    policies = rc.commands_parser.get_command_policies()
except redis.exceptions.IncorrectPolicyType as e:
    # unsupported response_policy value; upgrade client or patch module tips
    raise

Prevention

When it happens

Trigger: A command's tips contain 'response_policy:<unknown>' (e.g. a new aggregation strategy from a newer module); the client tries to coerce it via ResponsePolicy(value) and the ValueError is caught and re-raised as IncorrectPolicyType.

Common situations: Version skew between Redis/module and redis-py; experimental module advertising a response policy not yet in the enum; custom fork.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/6111fe1e97b49db4.json. Report an issue: GitHub.