{"id":"f6924f074a23de83","repo":"redis/redis-py","slug":"cluster-flushslots-is-intentionally-not-implemente","errorCode":null,"errorMessage":"CLUSTER FLUSHSLOTS is intentionally not implemented in the client.","messagePattern":"CLUSTER FLUSHSLOTS is intentionally not implemented in the client\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"redis/commands/cluster.py","lineNumber":1021,"sourceCode":"        self: AsyncClientProtocol, target_node: \"TargetNodesT\"\n    ) -> Awaitable[ClusterLinksResponse]: ...\n\n    def cluster_links(\n        self, target_node: \"TargetNodesT\"\n    ) -> ClusterLinksResponse | Awaitable[ClusterLinksResponse]:\n        \"\"\"\n        Each node in a Redis Cluster maintains a pair of long-lived TCP link with each\n        peer in the cluster: One for sending outbound messages towards the peer and one\n        for receiving inbound messages from the peer.\n\n        This command outputs information of all such peer links as an array.\n\n        For more information see https://redis.io/commands/cluster-links\n        \"\"\"\n        return self.execute_command(\"CLUSTER LINKS\", target_nodes=target_node)\n\n    def cluster_flushslots(self, target_nodes: \"TargetNodesT\" | None = None) -> None:\n        raise NotImplementedError(\n            \"CLUSTER FLUSHSLOTS is intentionally not implemented in the client.\"\n        )\n\n    def cluster_bumpepoch(self, target_nodes: \"TargetNodesT\" | None = None) -> None:\n        raise NotImplementedError(\n            \"CLUSTER BUMPEPOCH is intentionally not implemented in the client.\"\n        )\n\n    def readonly(self, target_nodes: \"TargetNodesT\" | None = None) -> ResponseT:\n        \"\"\"\n        Enables read queries.\n        The command will be sent to the default cluster node if target_nodes is\n        not specified.\n\n        For more information see https://redis.io/commands/readonly\n        \"\"\"\n        if target_nodes == \"replicas\" or target_nodes == \"all\":\n            # read_from_replicas will only be enabled if the READONLY command","sourceCodeStart":1003,"sourceCodeEnd":1039,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/cluster.py#L1003-L1039","documentation":"cluster_flushslots() unconditionally raises NotImplementedError. The client intentionally does not expose CLUSTER FLUSHSLOTS because flushing slots on a cluster node is a destructive cluster-administration operation that the maintainers chose not to wire up. There is no input that avoids it — calling the method is itself the error.","triggerScenarios":"Calling r.cluster_flushslots() on a RedisCluster client (sync or async). The method body at redis/commands/cluster.py:1020-1023 always raises before doing anything.","commonSituations":"Discovering the method via IDE autocomplete or dir() and assuming it works; migrating tooling from another client that exposes FLUSHSLOTS; test teardown scripts trying to wipe slot assignments.","solutions":["Stop calling cluster_flushslots — it is deliberately unsupported and will never execute.","If you truly need the behavior, run the raw command via r.execute_command('CLUSTER', 'FLUSHSLOTS') against a specific node, understanding the cluster-damaging consequences.","For test isolation, flush the node's data with FLUSHALL / FLUSHDB and rebuild the cluster instead of using FLUSHSLOTS."],"exampleFix":"# before\nr.cluster_flushslots()\n# after (only if you accept the risk, against one node)\nr.execute_command('CLUSTER', 'FLUSHSLOTS')","handlingStrategy":"validation","validationCode":"# There is no valid call. Guard by feature-checking instead:\nif hasattr(client, 'cluster_flushslots') and callable(client.cluster_flushslots):\n    # cluster_flushslots always raises NotImplementedError on the cluster client\n    raise RuntimeError('cluster_flushslots is intentionally unsupported; use raw execute_command if absolutely necessary')","typeGuard":"import redis\ndef supports_cluster_flushslots(client) -> bool:\n    # The method exists on the cluster client but always raises.\n    return False","tryCatchPattern":"try:\n    client.cluster_flushslots()\nexcept NotImplementedError:\n    # not supported; fall back to raw command only if you accept the risk\n    client.execute_command('CLUSTER', 'FLUSHSLOTS')","preventionTips":["Do not call cluster_flushslots; it is a deliberate no-op-by-exception.","For test teardown, FLUSHALL on nodes + cluster rebuild is the supported path."],"tags":["cluster","unsupported","flushslots","notimplemented"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}