{"record":{"id":"df1c3316a4e4f1b9","repo":"BerriAI/litellm","slug":"azure-document-intelligence-analysis-failed-erro","errorCode":null,"errorMessage":"Azure Document Intelligence analysis failed: {error_msg}","messagePattern":"Azure Document Intelligence analysis failed: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/ocr/document_intelligence/transformation.py","lineNumber":485,"sourceCode":"            response: HTTP response from operation endpoint\n\n        Returns:\n            Operation status string\n\n        Raises:\n            ValueError: If operation failed or status is unknown\n        \"\"\"\n        try:\n            result: Final = response.json()\n            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        \"\"\"","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py#L467-L503","documentation":"Raised during operation polling when Azure DI reports status 'failed'; the error message from Azure's response body (result['error']['message'], or 'Unknown error' if absent) is wrapped into a ValueError. This is an upstream analysis failure — the request itself was accepted, but Document Intelligence could not process the document.","triggerScenarios":"Polling an analyze operation whose JSON status is 'failed': corrupted or password-protected PDFs, unsupported formats, unreadable scans, documents exceeding Azure limits, or an Azure-side service failure. The inner error_msg carries Azure's specific reason.","commonSituations":"Processing user-uploaded files at scale (some corrupt/protected); scanned images too low quality; files over the page/size limits; free-tier throttling surfacing as failed operations.","solutions":["Read the wrapped error message — it is Azure's own failure reason; address that cause (repair file, remove password, convert format).","Pre-validate uploads client-side: check MIME type, size, page count against Azure DI limits before submitting.","Isolate per-document failures with try/except so one bad file doesn't kill a batch; optionally retry once for transient Azure failures."],"exampleFix":"# before\nresults = [litellm.aocr_document(model=m, document=d) for d in docs]  # one bad file aborts batch\n\n# after\nresults = []\nfor d in docs:\n    try:\n        results.append(litellm.aocr_document(model=m, document=d))\n    except ValueError as e:\n        if \"analysis failed\" in str(e):\n            results.append({\"doc\": d[\"document_url\"], \"error\": str(e)})  # quarantine bad file\n        else:\n            raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.aocr_document(model=m, document=doc)\nexcept ValueError as e:\n    if \"analysis failed\" in str(e):\n        mark_document_unprocessable(doc, reason=str(e))  # quarantine, continue batch\n    else:\n        raise","preventionTips":["Pre-validate PDFs: not encrypted, valid structure, within page/size limits.","Quarantine failed documents instead of aborting the whole batch."],"tags":["azure","document-intelligence","ocr","upstream-error","polling"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}