{"id":"f636f0441187549b","repo":"redis/redis-py","slug":"wrong-number-of-response-items-from-pipeline-execu-f636f0","errorCode":null,"errorMessage":"Wrong number of response items from pipeline execution","messagePattern":"Wrong number of response items from pipeline execution","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"critical","filePath":"redis/client.py","lineNumber":2069,"sourceCode":"            response = self.parse_response(connection, \"_\")\n        except ExecAbortError:\n            if errors:\n                raise errors[0][1]\n            raise\n\n        # EXEC clears any watched keys\n        self.watching = False\n\n        if response is None:\n            raise WatchError(\"Watched variable changed.\")\n\n        # put any parse errors into the response\n        for i, e in errors:\n            response.insert(i, e)\n\n        if len(response) != len(commands):\n            self.connection.disconnect()\n            raise ResponseError(\n                \"Wrong number of response items from pipeline execution\"\n            )\n\n        # find any errors in the response and raise if necessary\n        if raise_on_error:\n            self.raise_first_error(commands, response)\n\n        # We have to run response callbacks manually\n        data = []\n        for r, cmd in zip(response, commands):\n            if not isinstance(r, Exception):\n                args, options = cmd\n                # Remove keys entry, it needs only for cache.\n                options.pop(\"keys\", None)\n                command_name = args[0]\n                if command_name in self.response_callbacks:\n                    r = self.response_callbacks[command_name](r, **options)\n            data.append(r)","sourceCodeStart":2051,"sourceCodeEnd":2087,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/client.py#L2051-L2087","documentation":"Raised in `Pipeline._execute_transaction` after EXEC: the number of reply items returned by the server does not match the number of queued commands. This indicates protocol desynchronization — the client and server disagree on how many commands were in the transaction. The connection is forcibly disconnected (the socket is now out of sync) and a ResponseError is raised.","triggerScenarios":"Rare corruption of the command stream inside a MULTI/EXEC pipeline: e.g. a command silently produced no response frame (EMPTY_RESPONSE mishandling), a RESP3 push frame was consumed as a reply, or a custom response callback altered the response length. Also seen with parser bugs or non-standard proxies that mangle transaction replies.","commonSituations":"Using an intermediary (proxy, twemproxy, cluster proxy) that rewrites MULTI/EXEC replies; version skew between redis-py and Redis server; RESP3 push notifications interleaving with transaction replies; custom response_callbacks returning wrong-length data.","solutions":["Connect directly to a real Redis node (bypass proxies that may rewrite transaction replies).","Update redis-py and the Redis server to compatible versions; verify RESP2/RESP3 parity.","Remove or audit custom response_callbacks that might reshape EXEC replies.","Report the issue with full command list and server/proxy versions — this is an internal-invariant violation, not a usage error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from redis.exceptions import ResponseError\ntry:\n    pipe.execute()\nexcept ResponseError as e:\n    if 'Wrong number of response items' in str(e):\n        # protocol desync — recreate client/pipeline; report bug\n        log.error('pipeline reply mismatch: %s', e)\n    else:\n        raise","preventionTips":["Avoid proxies that rewrite MULTI/EXEC replies for pipeline use.","Keep redis-py and Redis server versions in sync.","Audit custom response_callbacks that touch transactional commands."],"tags":["pipeline","transaction","protocol","corruption"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}