{"record":{"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/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/cluster.py#L1003-L1039","documentation":"RedisCluster.cluster_flushslots() is a stub that always raises NotImplementedError. The method exists on the cluster commands surface (inherited shape) but the client intentionally does not implement CLUSTER FLUSHSLOTS, because flushing slots from a client is a destructive cluster-administration operation that should be performed via redis-cli or direct node administration, not through this driver.","triggerScenarios":"Calling client.cluster_flushslots() on a RedisCluster or redis.asyncio.RedisCluster instance, with any arguments. The body raises unconditionally; no target_nodes value avoids it.","commonSituations":"Porting scripts that call CLUSTER FLUSHSLOTS against standalone node connections; attempting cluster cleanup programmatically during test teardown; auto-completing from IDE suggestions without checking the method is implemented.","solutions":["Do not call cluster_flushslots() from this client; run `CLUSTER FLUSHSLOTS` via redis-cli against the specific node if you truly need it.","For clearing data, use FLUSHDB/FLUSHALL on individual nodes, or bring the cluster down and re-create it.","If you must call it from Python, open a direct Connection to the target node and run execute_command('CLUSTER FLUSHSLOTS') on that raw connection."],"exampleFix":"# before\nclient.cluster_flushslots()\n# after - use a raw node connection if absolutely required\nfrom redis import Redis\nRedis(host='node-host', port=7000).execute_command('CLUSTER FLUSHSLOTS')","handlingStrategy":"type-guard","validationCode":"def safe_cluster_flushslots(client):\n    if type(client).__name__ in ('RedisCluster', 'AsyncRedisCluster'):\n        raise NotImplementedError('cluster_flushslots is not supported on the cluster client; use a raw node connection')\n    return client.cluster_flushslots()","typeGuard":"from redis.cluster import RedisCluster\nfrom redis.asyncio.cluster import RedisCluster as AsyncRedisCluster\n\ndef is_cluster_client(client) -> bool:\n    return isinstance(client, (RedisCluster, AsyncRedisCluster))","tryCatchPattern":"try:\n    client.cluster_flushslots()\nexcept NotImplementedError:\n    # fall back to raw node connection or skip\n    pass","preventionTips":["Do not call cluster_flushslots() from application code; treat it as unavailable.","If you need FLUSHALL/FLUSHDB semantics, scope it per node with redis.Redis.","Audit IDE-completion-driven calls against the method docstring before using."],"tags":["redis-cluster","not-implemented","cluster-flushslots","intentional-stub"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}