{"record":{"id":"3981565cd82aee25","repo":"redis/redis-py","slug":"shard-hint-is-deprecated-in-cluster-mode-398156","errorCode":null,"errorMessage":"shard_hint is deprecated in cluster mode","messagePattern":"shard_hint is deprecated in cluster mode","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":1235,"sourceCode":"        from redis.keyspace_notifications import ClusterKeyspaceNotifications\n\n        return ClusterKeyspaceNotifications(\n            self,\n            key_prefix=key_prefix,\n            ignore_subscribe_messages=ignore_subscribe_messages,\n        )\n\n    def pipeline(self, transaction=None, shard_hint=None):\n        \"\"\"\n        Cluster impl:\n            Pipelines do not work in cluster mode the same way they\n            do in normal mode. Create a clone of this object so\n            that simulating pipelines will work correctly. Each\n            command will be called directly when used and\n            when calling execute() will only return the result stack.\n        \"\"\"\n        if shard_hint:\n            raise RedisClusterException(\"shard_hint is deprecated in cluster mode\")\n\n        return ClusterPipeline(\n            nodes_manager=self.nodes_manager,\n            commands_parser=self.commands_parser,\n            startup_nodes=self.nodes_manager.startup_nodes,\n            result_callbacks=self.result_callbacks,\n            cluster_response_callbacks=self.cluster_response_callbacks,\n            read_from_replicas=self.read_from_replicas,\n            load_balancing_strategy=self.load_balancing_strategy,\n            reinitialize_steps=self.reinitialize_steps,\n            retry=self.retry,\n            lock=self._lock,\n            transaction=transaction,\n            event_dispatcher=self._event_dispatcher,\n        )\n\n    def lock(\n        self,","sourceCodeStart":1217,"sourceCodeEnd":1253,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/cluster.py#L1217-L1253","documentation":"Raised as a RedisClusterException by pipeline() when shard_hint is passed with a truthy value. In standalone Redis, shard_hint selects a connection in a sharded pool, but Redis Cluster manages its own per-slot/per-node connection pools, so the concept does not apply and is explicitly rejected at cluster.py:1234-1235.","triggerScenarios":"Calling client.pipeline(transaction=True, shard_hint='something') on a RedisCluster instance. Any non-None truthy value for shard_hint triggers the guard.","commonSituations":"Porting code from redis.Redis (standalone) to RedisCluster that previously used shard_hint for a custom sharded connection pool, or copy-paste from a non-cluster example.","solutions":["Remove the shard_hint argument from your pipeline() call; the cluster client handles connection routing automatically.","If you were using shard_hint for manual sharding, rely on hash tags ({tag}) in keys to control slot placement instead."],"exampleFix":"// before\npipe = client.pipeline(transaction=True, shard_hint='shard1')\n\n// after\npipe = client.pipeline(transaction=True)","handlingStrategy":"validation","validationCode":"# Never pass shard_hint to pipeline() in cluster mode\n# Remove shard_hint entirely from the call","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Never pass shard_hint to RedisCluster.pipeline(); the cluster client manages connection routing.","When porting from standalone Redis, audit and remove shard_hint arguments.","Use hash tags ({tag}) if you need to control key slot placement."],"tags":["pipeline","deprecated","cluster","configuration"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}