{"record":{"id":"d84263c0177f1134","repo":"BerriAI/litellm","slug":"azure-document-intelligence-analysis-failed-with-s","errorCode":null,"errorMessage":"Azure Document Intelligence analysis failed with status: {operation.status}","messagePattern":"Azure Document Intelligence analysis failed with status: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/ocr/document_intelligence/transformation.py","lineNumber":609,"sourceCode":"        except SSRFError as ssrf_err:\n            raise ValueError(f\"Azure Document Intelligence: rejected polling URL ({ssrf_err})\")\n\n        poll_headers = {\"Ocp-Apim-Subscription-Key\": raw_response.request.headers.get(\"Ocp-Apim-Subscription-Key\", \"\")}\n        return operation_url, poll_headers\n\n    def _transform_completed_response(self, model: str, raw_response: httpx.Response) -> OCRResponse:\n        \"\"\"\n        Transform a completed Azure Document Intelligence analyze operation\n        into the Mistral OCR response shape, preserving Azure-native\n        `analyzeResult` fields (`content`, `tables`, `keyValuePairs`) as\n        top-level response fields.\n        \"\"\"\n        operation: Final = AzureDocumentIntelligenceOperation.model_validate(raw_response.json())\n\n        verbose_logger.debug(\"Azure Document Intelligence response status: %s\", operation.status)\n\n        if operation.status != \"succeeded\":\n            raise ValueError(f\"Azure Document Intelligence analysis failed with status: {operation.status}\")\n\n        analyze_result: Final = (\n            operation.analyzeResult if operation.analyzeResult is not None else AzureDocumentIntelligenceAnalyzeResult()\n        )\n        mistral_pages: Final = [self._transform_azure_page(azure_page) for azure_page in analyze_result.pages]\n        usage_info: Final = OCRUsageInfo(pages_processed=len(mistral_pages), doc_size_bytes=None)\n\n        return OCRResponse(\n            pages=mistral_pages,\n            model=model,\n            usage_info=usage_info,\n            object=\"ocr\",\n            content=analyze_result.content,\n            tables=analyze_result.tables,\n            keyValuePairs=analyze_result.keyValuePairs,\n        )\n\n    def transform_ocr_response(","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py#L591-L627","documentation":"Raised after polling completes when the final operation document's status is not 'succeeded'. The response is parsed into AzureDocumentIntelligenceOperation; a terminal status like 'failed' (or anything else) at transform time produces this ValueError naming the actual status. It complements the per-poll status check and fires in the response-transformation path (_transform_completed_response).","triggerScenarios":"The last poll (or the sync response) carrying status 'failed' — corrupted document, unsupported content, size limits — or an unexpected terminal status reaching the transformer; operation.status != 'succeeded' after the loop exits.","commonSituations":"Same root causes as analysis failure: protected/corrupt PDFs, oversized documents, low-quality scans, Azure service errors; also race conditions where a non-terminal poll slips through and lands here.","solutions":["Inspect the status in the error message; if 'failed', re-submit and capture Azure's analyzeResult/error details, then fix the document (format, protection, size).","Pre-screen documents client-side (valid PDF, not encrypted, within page/size limits).","Upgrade LiteLLM if a new terminal status is being reported unhandled."],"exampleFix":null,"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 with status\" in str(e):\n        record_failure(doc, status=str(e))\n        return None\n    raise","preventionTips":["Pre-screen documents (encryption, size, page count) before submitting.","Treat terminal non-succeeded statuses as per-document failures, not crashes."],"tags":["azure","document-intelligence","ocr","upstream-error","response-transform"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}