{"record":{"id":"0b98910896355c25","repo":"BerriAI/litellm","slug":"failed-to-parse-operation-response-e","errorCode":null,"errorMessage":"Failed to parse operation response: {e}","messagePattern":"Failed to parse operation response: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/videos/transformation.py","lineNumber":321,"sourceCode":"        {\n            \"name\": \"operations/generate_1234567890\",\n            \"metadata\": {...},\n            \"done\": false,\n            \"error\": {...}\n        }\n\n        We return this as a VideoObject with:\n        - id: operation name (used for polling)\n        - status: \"processing\"\n        - usage: includes duration_seconds and optional video_resolution for cost calculation\n        \"\"\"\n        response_data: Final = raw_response.json()\n\n        # Parse response using Pydantic model for type safety\n        try:\n            operation_response: Final = GeminiLongRunningOperationResponse(**response_data)\n        except Exception as e:\n            raise ValueError(f\"Failed to parse operation response: {e}\")\n\n        operation_name: Final = operation_response.name\n        if not operation_name:\n            raise ValueError(f\"No operation name in Veo response: {response_data}\")\n\n        if custom_llm_provider:\n            video_id = encode_video_id_with_provider(operation_name, custom_llm_provider, model)\n        else:\n            video_id = operation_name\n\n        video_obj: Final = VideoObject(\n            id=video_id,\n            object=\"video\",\n            status=\"processing\",\n            model=model,\n        )\n\n        usage_data: Final[dict[str, Any]] = {}","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/gemini/videos/transformation.py#L303-L339","documentation":"Thrown by transform_video_create_response after litellm.video_generation() returns from the Gemini (Veo) endpoint. The raw JSON body failed Pydantic validation against GeminiLongRunningOperationResponse, meaning Google returned a body whose fields are missing, unexpected, or of the wrong type (e.g. an error payload instead of an operation object). The original Pydantic message is embedded in '{e}', so it names the exact offending field.","triggerScenarios":"Calling litellm.video_generation(model='gemini/veo-3', ...) (or any 'gemini/' Veo model) where the API responds with a body that does not match the long-running-operation schema: an error JSON returned with HTTP 200, a proxy/gateway rewriting the payload, or a Veo schema change not yet modeled in your installed litellm version.","commonSituations":"Outdated litellm package after Google changed the Veo response shape; a corporate proxy returning an HTML/JSON error page; quota or safety errors delivered in a non-operation envelope; mocked/stubbed test servers returning minimal JSON.","solutions":["Run with litellm.set_verbose = True (or LITELLM_LOG=DEBUG) and inspect the raw response body contained in nearby logs to see what Google actually returned.","Upgrade litellm to the latest release (pip install -U litellm) so the GeminiLongRunningOperationResponse model matches the current Veo schema.","If the body is an error payload, fix the underlying cause (API key, quota, invalid model name, safety rejection) before retrying.","If the payload looks like a valid Veo operation but still fails to parse, open a litellm GitHub issue with the sanitized JSON so the Pydantic model can be updated."],"exampleFix":"# before\nvideo = litellm.video_generation(model=\"gemini/veo-3\", prompt=\"a cat surfing\")\n\n# after\ntry:\n    video = litellm.video_generation(model=\"gemini/veo-3\", prompt=\"a cat surfing\")\nexcept ValueError as e:\n    if \"Failed to parse operation response\" in str(e):\n        litellm.print_verbose(f\"Veo returned an unparseable body: {e}\")\n        raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    video = litellm.video_generation(model=\"gemini/veo-3\", prompt=prompt)\nexcept ValueError as e:\n    if \"Failed to parse operation response\" in str(e):\n        # unexpected Veo payload: log for triage, do not retry blindly\n        logger.error(\"veo schema mismatch: %s\", e)\n        raise\n    raise","preventionTips":["Pin a known-good litellm version and upgrade deliberately after checking Veo release notes.","Enable LITELLM_LOG=DEBUG in staging so raw provider payloads are captured when parse errors appear.","Wrap provider calls in a thin adapter so schema failures surface as one actionable error type in your app."],"tags":["veo","gemini","video-generation","pydantic","response-parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}