{"id":"5b61482f4f23bff1","repo":"redis/redis-py","slug":"method-script-load-for-pipeline-is-not-implement","errorCode":null,"errorMessage":"method script_load_for_pipeline() is not implemented","messagePattern":"method script_load_for_pipeline\\(\\) is not implemented","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":4113,"sourceCode":"\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\n\nclass PipelineStrategy(AbstractStrategy):\n    def __init__(self, pipe: ClusterPipeline):\n        super().__init__(pipe)","sourceCodeStart":4095,"sourceCodeEnd":4131,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/cluster.py#L4095-L4131","documentation":"ClusterPipeline.script_load_for_pipeline() routes to AbstractStrategy.script_load_for_pipeline() (redis/cluster.py:4111), which unconditionally raises. This helper exists on the standalone Pipeline to SCRIPT LOAD a script and stash its SHA for later EVAL within the same pipeline; the cluster pipeline cannot implement it because EVAL SHA dispatch depends on per-slot routing and the SHA must exist on every node that may execute it.","triggerScenarios":"Calling pipe.script_load_for_pipeline(script) on a RedisCluster pipeline. Path: ClusterPipeline.script_load_for_pipeline (redis/cluster.py:3742) -> strategy.script_load_for_pipeline() -> raises at redis/cluster.py:4113.","commonSituations":"Reusing a standalone pipeline helper that bundles SCRIPT LOAD + EVALSHA in one pipeline against a cluster. Older tutorial/sample code copied into a cluster app.","solutions":["SCRIPT LOAD the script on all primaries with rc.script_load(script, target_nodes=RedisCluster.PRIMARIES), then issue EVALSHA on the client within the pipeline body.","Switch to Redis Functions (FUNCTION LOAD) which cluster-routes correctly, eliminating the need for this helper.","Drop the call if you only need EVAL (not EVALSHA); use rc.eval(...) directly on the client."],"exampleFix":"# before\npipe = rc.pipeline()\npipe.script_load_for_pipeline(script)\n\n# after\nsha = rc.script_load(script, target_nodes=RedisCluster.PRIMARIES)\npipe.set('k', 'v')  # build your pipeline normally\nrc.evalsha(sha, numkeys, *keys)","handlingStrategy":"validation","validationCode":"from redis.cluster import RedisCluster\n\ndef preload_for_pipeline(client, script):\n    if isinstance(client, RedisCluster):\n        return client.script_load(script, target_nodes=RedisCluster.PRIMARIES)\n    pipe = client.pipeline()\n    pipe.script_load_for_pipeline(script)\n    pipe.execute()\n    return None","typeGuard":"from redis.cluster import RedisCluster\n\ndef is_cluster_client(client) -> bool:\n    return isinstance(client, RedisCluster)","tryCatchPattern":"from redis.exceptions import RedisClusterException\n\ntry:\n    pipe.script_load_for_pipeline(script)\nexcept RedisClusterException:\n    sha = rc.script_load(script, target_nodes=RedisCluster.PRIMARIES)","preventionTips":["Replace script_load_for_pipeline() with explicit SCRIPT LOAD on all primaries for cluster.","Use EVAL directly on the client or FCALL via Functions.","Document the cluster incompatibility of this helper anywhere it appears."],"tags":["cluster","pipeline","scripting","not-implemented"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}