BerriAI/litellm · error · ValueError

Azure Document Intelligence: rejected polling URL

Error message

Azure Document Intelligence: rejected polling URL ({ssrf_err})

What it means

Error "Azure Document Intelligence: rejected polling URL ({ssrf_err})" thrown in BerriAI/litellm.

Solutions

  1. The polling URL failed SSRF validation; ensure the endpoint is your trusted Azure resource and not a redirect.

When it happens

Trigger: Thrown at litellm/llms/azure_ai/ocr/document_intelligence/transformation.py:592 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/a20ae2cabb618889. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure_ai/ocr/document_intelligence/transformation.py:592

            if status == "succeeded":
                return response
            elif status == "running":
                # Wait before polling again
                retry_after = self._get_retry_after(response=response)
                await asyncio.sleep(retry_after)

    def _get_polling_target(self, raw_response: httpx.Response) -> tuple[str, dict[str, str]]:
        operation_url: Final = raw_response.headers.get("Operation-Location")
        if not operation_url:
            raise ValueError("Azure Document Intelligence returned 202 but no Operation-Location header found")

        # Reject cross-origin polling URLs — the auth headers
        # below would otherwise leak to whatever URL the upstream
        # (or an attacker-controlled upstream) returns. VERIA-51.
        try:
            assert_same_origin(operation_url, str(raw_response.request.url))
        except SSRFError as ssrf_err:
            raise ValueError(f"Azure Document Intelligence: rejected polling URL ({ssrf_err})")

        poll_headers = {"Ocp-Apim-Subscription-Key": raw_response.request.headers.get("Ocp-Apim-Subscription-Key", "")}
        return operation_url, poll_headers

    def _transform_completed_response(self, model: str, raw_response: httpx.Response) -> OCRResponse:
        """
        Transform a completed Azure Document Intelligence analyze operation
        into the Mistral OCR response shape, preserving Azure-native
        `analyzeResult` fields (`content`, `tables`, `keyValuePairs`) as
        top-level response fields.
        """
        operation: Final = AzureDocumentIntelligenceOperation.model_validate(raw_response.json())

        verbose_logger.debug("Azure Document Intelligence response status: %s", operation.status)

        if operation.status != "succeeded":
            raise ValueError(f"Azure Document Intelligence analysis failed with status: {operation.status}")

View on GitHub (pinned to 77b7c6c40c)