{"record":{"id":"fd52a95fc0ca90e8","repo":"BerriAI/litellm","slug":"document-url-is-required","errorCode":null,"errorMessage":"Document URL is required","messagePattern":"Document URL is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/ocr/document_intelligence/transformation.py","lineNumber":373,"sourceCode":"        \"\"\"\n        verbose_logger.debug(\"Azure Document Intelligence transform_ocr_request - model: %s\", model)\n\n        if not isinstance(document, dict):\n            raise ValueError(f\"Expected document dict, got {type(document)}\")\n\n        # Extract document URL from Mistral format\n        doc_type: Final = document.get(\"type\")\n        document_url = None\n\n        if doc_type == \"document_url\":\n            document_url = document.get(\"document_url\", \"\")\n        elif doc_type == \"image_url\":\n            document_url = document.get(\"image_url\", \"\")\n        else:\n            raise ValueError(f\"Invalid document type: {doc_type}. Must be 'document_url' or 'image_url'\")\n\n        if not document_url:\n            raise ValueError(\"Document URL is required\")\n\n        # Build Azure DI request\n        data: Final[dict[str, Any]] = {}\n\n        # Check if it's a data URI (base64)\n        if document_url.startswith(\"data:\"):\n            # Extract base64 content\n            base64_content: Final = self._extract_base64_from_data_uri(document_url)\n            data[\"base64Source\"] = base64_content\n            verbose_logger.debug(\"Using base64Source for Azure Document Intelligence\")\n        else:\n            # Regular URL\n            data[\"urlSource\"] = document_url\n            verbose_logger.debug(\"Using urlSource for Azure Document Intelligence\")\n\n        # Azure DI: `pages` is a query param (wired in get_complete_url),\n        # not a body field. Other Mistral-specific params (e.g.\n        # include_image_base64, image_limit) are unsupported and ignored.","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py#L355-L391","documentation":"Raised when the document dict has a valid type but the corresponding URL field is empty/missing — e.g. type 'document_url' with no 'document_url' value, or an empty string. Azure DI needs either a reachable URL or a base64 data URI to analyze, so the request cannot be built and fails client-side.","triggerScenarios":"Calling azure_ai doc-intelligence OCR with {'type': 'document_url', 'document_url': ''}, a dict missing the URL key (document.get returns ''), or a falsy value like None under the URL key.","commonSituations":"Building the dict from optional form fields that were left blank; key-name mismatch ('url' instead of 'document_url'); earlier processing step returned an empty string for the upload URL.","solutions":["Supply a non-empty http(s) URL under the key matching the type, or a data URI like 'data:application/pdf;base64,...'.","Check for empty/missing URL before calling and return a user-facing validation error.","If uploading to blob storage first, verify the upload succeeded and the SAS URL was actually returned."],"exampleFix":"# before\ndoc = {\"type\": \"document_url\", \"document_url\": upload_result.get(\"url\", \"\")}  # empty on failure\n\n# after\nurl = upload_result.get(\"url\")\nif not url:\n    raise ValueError(\"upload failed; no document URL\")\ndoc = {\"type\": \"document_url\", \"document_url\": url}","handlingStrategy":"validation","validationCode":"def document_with_url(doc: dict) -> bool:\n    return bool(doc.get(doc.get(\"type\", \"\"), \"\"))  # URL key must match type and be non-empty","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast client-side when an upload returns an empty URL.","Match the URL key to the type ('document_url' vs 'image_url')."],"tags":["azure","document-intelligence","ocr","validation","request-format"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}