{"record":{"id":"4e75bb81868c5a48","repo":"redis/redis-py","slug":"slot-slot-is-not-covered-by-the-cluster-4e75bb","errorCode":null,"errorMessage":"Slot \"{slot}\" is not covered by the cluster.","messagePattern":"Slot \"(.+?)\" is not covered by the cluster\\.","errorType":"exception","errorClass":"SlotNotCoveredError","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":1071,"sourceCode":"        \"\"\"\n        if self.read_from_replicas and command_name in READ_COMMANDS:\n            return self.get_random_node()\n\n        return self.get_random_primary_node()\n\n    def get_nodes(self):\n        return list(self.nodes_manager.nodes_cache.values())\n\n    def get_node_from_key(self, key, replica=False):\n        \"\"\"\n        Get the node that holds the key's slot.\n        If replica set to True but the slot doesn't have any replicas, None is\n        returned.\n        \"\"\"\n        slot = self.keyslot(key)\n        slot_cache = self.nodes_manager.slots_cache.get(slot)\n        if slot_cache is None or len(slot_cache) == 0:\n            raise SlotNotCoveredError(f'Slot \"{slot}\" is not covered by the cluster.')\n        if replica and len(self.nodes_manager.slots_cache[slot]) < 2:\n            return None\n        elif replica:\n            node_idx = 1\n        else:\n            # primary\n            node_idx = 0\n\n        return slot_cache[node_idx]\n\n    def get_default_node(self):\n        \"\"\"\n        Get the cluster's default node\n        \"\"\"\n        return self.nodes_manager.default_node\n\n    def get_nodes_from_slot(self, command: str, *args):\n        \"\"\"","sourceCodeStart":1053,"sourceCodeEnd":1089,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/cluster.py#L1053-L1089","documentation":"Raised as a SlotNotCoveredError by get_node_from_key() when the computed hash slot for the given key has no entry in the cluster's slots_cache. This means the client's local view of the cluster topology has no node assigned to that slot, typically because topology discovery has not run, slots moved, or the cluster is degraded. SlotNotCoveredError is a subclass of RedisClusterException whose docstring instructs the client to drop the node layout and reconnect/refresh.","triggerScenarios":"Calling client.get_node_from_key(key) or any code path that resolves a key to a node (e.g., shard-channel operations) when the key's slot is absent from nodes_manager.slots_cache. The check at cluster.py:1069-1071 fires when slot_cache is None or empty.","commonSituations":"Cluster is mid-failover or resharding, a slot was moved to a node the client hasn't discovered yet, the initial topology refresh failed to populate all slots, or the cluster is in a degraded state with unassigned slots.","solutions":["Trigger a topology refresh by catching the error and calling client.cluster_reload_slots() or reinitializing the client.","Retry the operation after a short backoff to allow the cluster to complete failover/resharding.","Ensure the cluster has full slot coverage (CLUSTER NODES / CLUSTER SLOTS) and all primaries are healthy.","If persistent, set require_full_coverage appropriately and verify no nodes are in FAIL or PFAIL state."],"exampleFix":"// before\nnode = client.get_node_from_key('mykey')\n\n// after\nfrom redis.exceptions import SlotNotCoveredError\ntry:\n    node = client.get_node_from_key('mykey')\nexcept SlotNotCoveredError:\n    client.cluster_reload_slots()\n    node = client.get_node_from_key('mykey')","handlingStrategy":"retry","validationCode":"from redis.cluster import key_slot\nslot = key_slot(b'mykey') % 16384\nnode = client.nodes_manager.slots_cache.get(slot)\nif not node:\n    client.cluster_reload_slots()  # refresh before proceeding","typeGuard":"def is_slot_covered(client, key: str) -> bool:\n    slot = client.keyslot(key)\n    cache = client.nodes_manager.slots_cache.get(slot)\n    return cache is not None and len(cache) > 0","tryCatchPattern":"from redis.exceptions import SlotNotCoveredError\ntry:\n    node = client.get_node_from_key(key)\nexcept SlotNotCoveredError:\n    client.cluster_reload_slots()\n    node = client.get_node_from_key(key)","preventionTips":["Catch SlotNotCoveredError and trigger a topology refresh before retrying.","Ensure the cluster has full slot coverage during normal operation.","Use require_full_coverage=True to fail fast at startup rather than mid-operation."],"tags":["slot-coverage","topology","cluster","failover"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}