{"record":{"id":"f098908bfb36b217","repo":"redis/redis-py","slug":"method-eval-is-not-implemented","errorCode":null,"errorMessage":"method eval() is not implemented","messagePattern":"method eval\\(\\) is not implemented","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":4118,"sourceCode":"    def execute(self, raise_on_error: bool = True) -> List[Any]:\n        pass\n\n    @abstractmethod\n    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 \"","sourceCodeStart":4100,"sourceCodeEnd":4136,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/cluster.py#L4100-L4136","documentation":"Raised as a RedisClusterException by the eval() method on the abstract PipelineCommandExecutionStrategy base class (cluster.py:4116-4118). The base execution strategy does not implement eval/load_scripts/script_load_for_pipeline because cluster pipelines handle Lua script loading differently (via the concrete execution strategy subclasses). Calling eval() on a pipeline whose execution strategy is the abstract base indicates a misconfigured or partially-constructed pipeline object.","triggerScenarios":"Calling pipe.eval() or pipe.load_scripts() on a ClusterPipeline whose _execution_strategy is the abstract base class rather than a concrete subclass. Also raised by load_scripts() and script_load_for_pipeline() on the same base.","commonSituations":"Attempting to use Lua scripting through the pipeline API in a way that reaches the abstract base, or a subclass was not properly selected during pipeline construction.","solutions":["Do not call eval() through the cluster pipeline; register scripts on the client first with client.script_load(script), then use pipe.evalsha(sha1, numkeys, *keys) in the pipeline.","Run EVAL/EVALSHA directly on the client (not the pipeline) if you need scripting outside the pipeline abstraction.","Ensure you are using the standard ClusterPipeline from client.pipeline() so the concrete execution strategy is wired up."],"exampleFix":"// before\npipe = client.pipeline()\npipe.eval('return 1', 0)\n\n// after\nsha = client.script_load('return 1')\npipe.evalsha(sha, 0)","handlingStrategy":"validation","validationCode":"# Pre-load scripts and use evalsha in the pipeline instead of eval\nsha = client.script_load('return 1')\npipe = client.pipeline()\npipe.evalsha(sha, 0)\nresults = pipe.execute()","typeGuard":"def is_eval_on_pipeline(method_name: str) -> bool:\n    return method_name in ('eval', 'load_scripts', 'script_load_for_pipeline')","tryCatchPattern":"from redis.exceptions import RedisClusterException\ntry:\n    pipe.eval('return 1', 0)\nexcept RedisClusterException as e:\n    if 'not implemented' in str(e):\n        sha = client.script_load('return 1')\n        pipe.evalsha(sha, 0)","preventionTips":["Do not call eval() on cluster pipelines; use client.script_load() then pipe.evalsha().","Run EVAL/EVALSHA directly on the client outside the pipeline if needed.","Always obtain the pipeline from client.pipeline() to ensure the concrete execution strategy is wired."],"tags":["pipeline","eval","lua-scripting","abstract-method","cluster"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}