{"record":{"id":"ccf0e7be2956a654","repo":"redis/redis-py","slug":"incorrect-request-policy-type-policy-type","errorCode":null,"errorMessage":"Incorrect request policy type: {policy_type}","messagePattern":"Incorrect request policy type: (.+?)","errorType":"exception","errorClass":"IncorrectPolicyType","httpStatus":null,"severity":"error","filePath":"redis/_parsers/commands.py","lineNumber":297,"sourceCode":"                command_name: The command name to associate with found policies\n            \"\"\"\n            if isinstance(data, (str, bytes)):\n                # Decode bytes to string if needed\n                policy = str_if_bytes(data.decode())\n\n                # Check if this is a policy string\n                if policy.startswith(\"request_policy\") or policy.startswith(\n                    \"response_policy\"\n                ):\n                    if policy.startswith(\"request_policy\"):\n                        policy_type = policy.split(\":\")[1]\n\n                        try:\n                            command_with_policies[module_name][\n                                command_name\n                            ].request_policy = RequestPolicy(policy_type)\n                        except ValueError:\n                            raise IncorrectPolicyType(\n                                f\"Incorrect request policy type: {policy_type}\"\n                            )\n\n                    if policy.startswith(\"response_policy\"):\n                        policy_type = policy.split(\":\")[1]\n\n                        try:\n                            command_with_policies[module_name][\n                                command_name\n                            ].response_policy = ResponsePolicy(policy_type)\n                        except ValueError:\n                            raise IncorrectPolicyType(\n                                f\"Incorrect response policy type: {policy_type}\"\n                            )\n\n            elif isinstance(data, list):\n                # For lists, recursively process each element\n                for item in data:","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/_parsers/commands.py#L279-L315","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade redis-py to a version whose RequestPolicy enum includes the new policy value.","Align/downgrade the Redis server or module to a version whose tips this client understands.","If from a custom module, fix the module's tip to use a standard RequestPolicy value.","Report the unrecognized policy string to redis-py maintainers with the COMMAND output."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# Verify the server-advertised request_policy tip is a known enum value\nfrom redis._parsers.commands import RequestPolicy\nvalid = {m.value for m in RequestPolicy}\nif policy_value not in valid:\n    raise ValueError(f\"unsupported request_policy: {policy_value}; upgrade redis-py\")","typeGuard":null,"tryCatchPattern":"from redis.exceptions import IncorrectPolicyType\ntry:\n    policies = parser.get_command_policies()\nexcept IncorrectPolicyType as e:\n    # version skew: newer server advertised an unknown request_policy\n    # -> upgrade redis-py or align server version\n    ...","preventionTips":["Keep redis-py and the Redis server/module versions aligned.","For custom modules, emit only standard RequestPolicy tip values.","Pin server versions in mixed clusters to avoid advertising unknown policies."],"tags":["cluster","policies","version-skew","module"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}