{"record":{"id":"73c95bf2690e77e3","repo":"BerriAI/litellm","slug":"error-parsing-chunk-e-nreceived-chunk-chunk","errorCode":null,"errorMessage":"Error parsing chunk: {e},\\nReceived chunk: {chunk}","messagePattern":"Error parsing chunk: (.+?),\\\\nReceived chunk: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py","lineNumber":3367,"sourceCode":"\n    def __next__(self):\n        try:\n            chunk: Final = self.response_iterator.__next__()\n        except StopIteration:\n            if self.chunk_type == \"accumulated_json\" and self.accumulated_json:\n                result: Final = self.handle_accumulated_json_chunk(chunk=\"\", is_final=True)\n                if result is not None:\n                    return result\n            raise StopIteration\n        except ValueError as e:\n            raise RuntimeError(f\"Error receiving chunk from stream: {e}\")\n\n        try:\n            return self._common_chunk_parsing_logic(chunk=chunk)\n        except StopIteration:\n            raise StopIteration\n        except ValueError as e:\n            raise RuntimeError(f\"Error parsing chunk: {e},\\nReceived chunk: {chunk}\")\n\n    # Async iterator\n    def __aiter__(self):\n        self.async_response_iterator = self.streaming_response.__aiter__()\n        return self\n\n    async def __anext__(self):\n        try:\n            chunk: Final = await self.async_response_iterator.__anext__()\n        except StopAsyncIteration:\n            if self.chunk_type == \"accumulated_json\" and self.accumulated_json:\n                result: Final = self.handle_accumulated_json_chunk(chunk=\"\", is_final=True)\n                if result is not None:\n                    return result\n            raise StopAsyncIteration\n        except ValueError as e:\n            raise RuntimeError(f\"Error receiving chunk from stream: {e}\")\n","sourceCodeStart":3349,"sourceCodeEnd":3385,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py#L3349-L3385","documentation":"Except-handler in ModelResponseIterator chunk parsing: _common_chunk_parsing_logic raised while transforming the raw chunk into a ModelResponse; both the exception and the offending chunk are embedded so the malformed payload can be inspected.","triggerScenarios":"Triggered when parsing a Vertex AI Gemini stream chunk raises an exception.","commonSituations":"See trigger scenarios.","solutions":["Inspect the logged chunk and parse error; the stream chunk format was unexpected.","Check for proxy interference or an API schema change."],"exampleFix":"# log chunk content and adapt parsing or upgrade litellm.","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}