{"record":{"id":"ad80d11a14020fea","repo":"BerriAI/litellm","slug":"failed-to-parse-azure-di-operation-response-e","errorCode":null,"errorMessage":"Failed to parse Azure DI operation response: {e}","messagePattern":"Failed to parse Azure DI operation response: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/ocr/document_intelligence/transformation.py","lineNumber":495,"sourceCode":"            status: Final = result.get(\"status\")\n\n            verbose_logger.debug(\"Azure DI operation status: %s\", status)\n\n            if status == \"succeeded\":\n                return \"succeeded\"\n            elif status == \"failed\":\n                error_msg: Final = result.get(\"error\", {}).get(\"message\", \"Unknown error\")\n                raise ValueError(f\"Azure Document Intelligence analysis failed: {error_msg}\")\n            elif status in [\"running\", \"notStarted\"]:\n                return \"running\"\n            else:\n                raise ValueError(f\"Unknown operation status: {status}\")\n\n        except Exception as e:\n            if \"succeeded\" in str(e) or \"failed\" in str(e):\n                raise\n            # If we can't parse JSON, something went wrong\n            raise ValueError(f\"Failed to parse Azure DI operation response: {e}\")\n\n    def _poll_operation_sync(\n        self,\n        operation_url: str,\n        headers: dict[str, str],\n        timeout_secs: int,\n    ) -> httpx.Response:\n        \"\"\"\n        Poll Azure Document Intelligence operation until completion (sync).\n\n        Azure DI POST returns 202 with Operation-Location header.\n        We need to poll that URL until status is \"succeeded\" or \"failed\".\n\n        Args:\n            operation_url: The Operation-Location URL to poll\n            headers: Request headers (including auth)\n            timeout_secs: Total timeout in seconds\n","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py#L477-L513","documentation":"Catch-all parse failure while checking an Azure DI operation-status response: response.json() threw, or evaluating the body raised, and the exception text did not contain 'succeeded'/'failed' (those are re-raised as-is). It means the polled URL did not return the expected JSON operation document — most often an auth error page, an HTML 404/401 from an expired operation URL, or a proxy interception.","triggerScenarios":"Polling an Operation-Location URL that expired or was invalidated (key rotated mid-operation); the subscription key being wrong so the poll returns a non-JSON error; a gateway returning HTML; the operation URL being malformed.","commonSituations":"Long analyses outliving operation URLs; credential rotation during processing; misconfigured proxies; mocking frameworks returning plain text.","solutions":["Check the embedded exception text — it usually reveals a JSONDecodeError on an HTML/plain-text body, pointing at auth or URL problems.","Verify AZURE_DOCUMENT_INTELLIGENCE_API_KEY is still valid and matches the resource that issued the operation URL.","Reduce total processing time (smaller docs) or retry the whole analyze operation fresh if the operation URL expired."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.aocr_document(model=m, document=doc)\nexcept ValueError as e:\n    if \"Failed to parse Azure DI operation response\" in str(e):\n        # likely auth/URL issue mid-poll: verify key, then retry fresh once\n        verify_di_credentials()\n        resp = litellm.aocr_document(model=m, document=doc)\n    else:\n        raise","preventionTips":["Avoid rotating DI credentials while long analyses are in flight.","Keep documents small enough to finish well within operation URL lifetimes."],"tags":["azure","document-intelligence","ocr","json-parse","polling","authentication"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}