{"record":{"id":"feb1da68ea3962b9","repo":"redis/redis-py","slug":"method-load-scripts-is-not-implemented","errorCode":null,"errorMessage":"method load_scripts() is not implemented","messagePattern":"method load_scripts\\(\\) is not implemented","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":4122,"sourceCode":"    def send_cluster_commands(\n        self, stack, raise_on_error=True, allow_redirections=True\n    ):\n        pass\n\n    @abstractmethod\n    def reset(self):\n        pass\n\n    def exists(self, *keys):\n        return self.execute_command(\"EXISTS\", *keys)\n\n    def eval(self):\n        \"\"\" \"\"\"\n        raise RedisClusterException(\"method eval() is not implemented\")\n\n    def load_scripts(self):\n        \"\"\" \"\"\"\n        raise RedisClusterException(\"method load_scripts() is not implemented\")\n\n    def script_load_for_pipeline(self, *args, **kwargs):\n        \"\"\" \"\"\"\n        raise RedisClusterException(\n            \"method script_load_for_pipeline() is not implemented\"\n        )\n\n    def annotate_exception(self, exception, number, command):\n        \"\"\"\n        Provides extra context to the exception prior to it being handled\n        \"\"\"\n        cmd = \" \".join(map(safe_str, command))\n        msg = (\n            f\"Command # {number} ({truncate_text(cmd)}) of pipeline \"\n            f\"caused error: {exception.args[0]}\"\n        )\n        exception.args = (msg,) + exception.args[1:]\n","sourceCodeStart":4104,"sourceCodeEnd":4140,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/cluster.py#L4104-L4140","documentation":"Raised by AbstractStrategy.load_scripts() in redis/cluster.py:4122. In a standalone Redis client, pipelines call SCRIPT LOAD to pre-load Lua scripts so EVALSHA can be used; in Redis Cluster a script must be loaded on every primary, and this method is intentionally left unimplemented on the base strategy. The cluster pipeline handles script loading through a different code path (execute_command of EVAL/EVALSHA), so calling this method directly is a misuse of the API.","triggerScenarios":"Calling the load_scripts() method directly on a ClusterPipeline instance or on an AbstractStrategy subclass that does not override it: e.g. pipe.load_scripts() where pipe = rc.pipeline() from a RedisCluster client.","commonSituations":"Code ported verbatim from a standalone redis.Redis pipeline to a redis.cluster.RedisCluster pipeline without removing the explicit SCRIPT LOAD warm-up step; test harnesses that call load_scripts() generically across client types.","solutions":["Remove the explicit load_scripts() call from your cluster pipeline code; let EVAL/EVALSHA handle script loading automatically through execute_command.","If you need a script loaded on all nodes, execute SCRIPT LOAD manually against each primary via rc.cluster_execute_command('SCRIPT LOAD', script, target_nodes='primaries').","Switch to a non-cluster Redis client if you genuinely need the standalone pipeline load_scripts() semantics."],"exampleFix":"// before\npipe = rc.pipeline()\npipe.load_scripts()\n// after\n# no explicit load_scripts() needed; EVAL/EVALSHA loads lazily\npipe = rc.pipeline()","handlingStrategy":"validation","validationCode":"from redis.cluster import RedisCluster\nis_cluster = isinstance(rc, RedisCluster)\nif not is_cluster:\n    pipe.load_scripts()  # safe only on standalone","typeGuard":"def supports_load_scripts(client) -> bool:\n    from redis.cluster import RedisCluster\n    return not isinstance(client, RedisCluster)","tryCatchPattern":"from redis.exceptions import RedisClusterException\ntry:\n    pipe.load_scripts()\nexcept RedisClusterException:\n    pass  # not supported on cluster pipelines","preventionTips":["Audit pipeline code when migrating standalone to cluster.","Gate standalone-only optimizations behind a client-type check."],"tags":["cluster","pipeline","lua-scripting","api-misuse"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}