{"record":{"id":"a4744b40cf9711a0","repo":"BerriAI/litellm","slug":"chunk-cannot-be-parsed-as-ocistreamchunk-e","errorCode":null,"errorMessage":"Chunk cannot be parsed as OCIStreamChunk: {e}","messagePattern":"Chunk cannot be parsed as OCIStreamChunk: (.+?)","errorType":"exception","errorClass":"OCIError","httpStatus":500,"severity":"error","filePath":"litellm/llms/oci/chat/generic.py","lineNumber":372,"sourceCode":"        reasoning_tokens=reasoning_tokens,\n    )\n\n    return model_response\n\n\ndef handle_generic_stream_chunk(dict_chunk: dict) -> ModelResponseStream:\n    \"\"\"Parse a single GENERIC SSE chunk into a LiteLLM ModelResponseStream.\"\"\"\n    # OCI streams tool calls progressively — early chunks may omit required fields.\n    if dict_chunk.get(\"message\") and dict_chunk[\"message\"].get(\"toolCalls\"):\n        for tool_call in dict_chunk[\"message\"][\"toolCalls\"]:\n            tool_call.setdefault(\"arguments\", \"\")\n            tool_call.setdefault(\"id\", \"\")\n            tool_call.setdefault(\"name\", \"\")\n\n    try:\n        typed_chunk: Final = OCIStreamChunk(**dict_chunk)\n    except (TypeError, ValidationError) as e:\n        raise OCIError(\n            status_code=500,\n            message=f\"Chunk cannot be parsed as OCIStreamChunk: {e}\",\n        )\n\n    if typed_chunk.index is None:\n        typed_chunk.index = 0\n\n    # Emit ``content=None`` rather than ``content=\"\"`` on chunks with no text\n    # parts (e.g. tool-call-only or keep-alive chunks) so downstream\n    # stream-mergers that distinguish \"no text in this delta\" from \"an\n    # explicitly empty text delta\" behave correctly.\n    text: str | None = None\n    if typed_chunk.message and typed_chunk.message.content:\n        for item in typed_chunk.message.content:\n            if isinstance(item, OCITextContentPart):\n                text = (text or \"\") + item.text\n            elif isinstance(item, OCIImageContentPart):\n                raise OCIError(","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/chat/generic.py#L354-L390","documentation":"Error \"Chunk cannot be parsed as OCIStreamChunk: {e}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/oci/chat/generic.py:372 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The OCI stream chunk did not match the expected schema; see the wrapped exception."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}