{"record":{"id":"b22ab57ae64e6738","repo":"redis/redis-py","slug":"invalid-option-for-cluster-failover-command-opti","errorCode":null,"errorMessage":"Invalid option for CLUSTER FAILOVER command: {option}","messagePattern":"Invalid option for CLUSTER FAILOVER command: (.+?)","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/commands/cluster.py","lineNumber":644,"sourceCode":"        target_node: \"TargetNodesT\",\n        option: str | None = None,\n    ) -> Awaitable[bool]: ...\n\n    def cluster_failover(\n        self, target_node: \"TargetNodesT\", option: str | None = None\n    ) -> bool | Awaitable[bool]:\n        \"\"\"\n        Forces a slave to perform a manual failover of its master\n        Sends to specified node\n\n        :target_node: 'ClusterNode'\n            The node to execute the command on\n\n        For more information see https://redis.io/commands/cluster-failover\n        \"\"\"\n        if option:\n            if option.upper() not in [\"FORCE\", \"TAKEOVER\"]:\n                raise RedisError(\n                    f\"Invalid option for CLUSTER FAILOVER command: {option}\"\n                )\n            else:\n                return self.execute_command(\n                    \"CLUSTER FAILOVER\", option, target_nodes=target_node\n                )\n        else:\n            return self.execute_command(\"CLUSTER FAILOVER\", target_nodes=target_node)\n\n    @overload\n    def cluster_info(\n        self: SyncClientProtocol, target_nodes: \"TargetNodesT\" | None = None\n    ) -> dict[str, str]: ...\n\n    @overload\n    def cluster_info(\n        self: AsyncClientProtocol, target_nodes: \"TargetNodesT\" | None = None\n    ) -> Awaitable[dict[str, str]]: ...","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/cluster.py#L626-L662","documentation":"Raised by ClusterManagementCommands.cluster_failover() in redis/commands/cluster.py:644 as a RedisError when the option argument is not one of the two valid values FORCE or TAKEOVER (case-insensitive). The CLUSTER FAILOVER command accepts only those options or none, so any other string is rejected before sending.","triggerScenarios":"Calling rc.cluster_failover(target_node, option='SYNC'), option='async', option=True, or any value other than 'FORCE'/'TAKEOVER'/None.","commonSituations":"Typos in the option string; passing a boolean or non-string; mismatched casing assumptions beyond upper/lower; passing 'FORCE ' with trailing whitespace.","solutions":["Pass option='FORCE', option='TAKEOVER', or option=None only.","Strip/upper-case user input before passing: option=value.strip().upper() if value else None.","Validate the option against {'FORCE','TAKEOVER'} before calling."],"exampleFix":"// before\nrc.cluster_failover(node, option='SYNC')\n// after\nrc.cluster_failover(node, option='FORCE')","handlingStrategy":"validation","validationCode":"VALID = {None, 'FORCE', 'TAKEOVER'}\noption = option.strip().upper() if isinstance(option, str) else option\nassert option in VALID, f'option must be one of {VALID}'\nrc.cluster_failover(node, option=option)","typeGuard":"def is_valid_failover_option(option) -> bool:\n    if option is None:\n        return True\n    return isinstance(option, str) and option.strip().upper() in {'FORCE','TAKEOVER'}","tryCatchPattern":"from redis.exceptions import RedisError\ntry:\n    rc.cluster_failover(node, option=option)\nexcept RedisError as e:\n    if 'Invalid option for CLUSTER FAILOVER' in str(e):\n        rc.cluster_failover(node, option='FORCE')","preventionTips":["Whitelist option to {'FORCE','TAKEOVER',None}.","Normalize user input with strip().upper() before passing."],"tags":["cluster","failover","validation","api-misuse"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}