{"record":{"id":"3f4ae515c907195b","repo":"BerriAI/litellm","slug":"invalid-azure-blob-storage-url-format-storage-ur","errorCode":null,"errorMessage":"Invalid Azure Blob Storage URL format: {storage_url}","messagePattern":"Invalid Azure Blob Storage URL format: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/files/azure_blob_storage_backend.py","lineNumber":242,"sourceCode":"        Download a file from Azure Blob Storage.\n\n        Args:\n            storage_url: Blob URL in format: https://{account}.blob.{endpoint_suffix}/{container}/{path}\n\n        Returns:\n            bytes: File content\n        \"\"\"\n        try:\n            # Parse blob URL to extract path\n            # URL format: https://{account}.blob.{endpoint_suffix}/{container}/{path}\n            parsed_url: Final = urlparse(storage_url)\n            if \".blob.\" not in (parsed_url.hostname or \"\"):\n                raise ValueError(f\"Invalid Azure Blob Storage URL: {storage_url}\")\n\n            # Extract path after container name\n            _, _, file_path = parsed_url.path.lstrip(\"/\").partition(\"/\")\n            if not file_path:\n                raise ValueError(f\"Invalid Azure Blob Storage URL format: {storage_url}\")\n\n            if self.azure_storage_account_key:\n                # Use Azure SDK (reuse logger's service client)\n                return await self._download_file_with_account_key(file_path)\n            else:\n                # Use REST API (reuse logger's token management)\n                return await self._download_file_with_azure_ad(file_path)\n\n        except Exception as e:\n            verbose_logger.exception(\"Error downloading file from Azure Blob Storage: %s\", e)\n            raise\n\n    async def _download_file_with_account_key(self, file_path: str) -> bytes:\n        \"\"\"Download file using Azure SDK with account key.\"\"\"\n        # Reuse the logger's service client method\n        service_client: Final = await self.get_service_client()\n        file_system_client: Final = service_client.get_file_system_client(file_system=self.azure_storage_file_system)\n        # Ensure filesystem exists (should already exist, but check for safety)","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/files/azure_blob_storage_backend.py#L224-L260","documentation":"Raised by AzureBlobStorageBackend after URL parsing succeeds but path extraction yields nothing: parsed_url.path stripped of '/' and partitioned on '/' leaves an empty file_path. This means the URL only had the container (e.g. .../container or .../container/) and no blob path, so there is no file to download.","triggerScenarios":"Passing a container-root URL like 'https://acct.blob.core.windows.net/container' or '.../container/' to the file download API; a stored file_url truncated during DB insert; blob names that were empty or stripped of slashes.","commonSituations":"Building download URLs by concatenating container + optional filename where filename is empty; frontend sending just the folder prefix; copy-paste of a container SAS URL instead of a blob URL.","solutions":["Include the full blob path after the container: https://{acct}.blob.core.windows.net/{container}/{blob/path.pdf}.","Check the code that generates/stores file_url for off-by-one or empty-filename bugs.","If listing files in a container was the intent, use the Azure SDK listing API instead of this download path.","URL-encode blob names containing spaces/special chars so the path segment is not lost."],"exampleFix":"# before\nstorage_url = 'https://acct.blob.core.windows.net/uploads/'  # no blob path -> ValueError\n\n# after\nstorage_url = 'https://acct.blob.core.windows.net/uploads/invoice-42.pdf'","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef has_blob_path(url: str) -> bool:\n    path = urlparse(url).path.lstrip('/')\n    _, _, file_path = path.partition('/')\n    return bool(file_path)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build download URLs as f'{container_url}/{blob_name}' and assert blob_name is non-empty.","Reject empty filenames at upload time so stored URLs are always complete.","Unit-test URL construction for edge cases (root path, trailing slash)."],"tags":["azure","blob-storage","url-validation","file-download"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}