{"record":{"id":"9541fc8e67116ce3","repo":"BerriAI/litellm","slug":"no-supported-extensions-for-mime-type-mime-type","errorCode":null,"errorMessage":"No supported extensions for MIME type: {mime_type}. Supported formats: {supported_doc_formats}","messagePattern":"No supported extensions for MIME type: (.+?)\\. Supported formats: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/prompt_templates/factory.py","lineNumber":3516,"sourceCode":"        potential_extensions: Final = mimetypes.guess_all_extensions(mime_type, strict=False)\n        valid_extensions = [ext[1:] for ext in potential_extensions if ext[1:] in supported_doc_formats]\n\n        # Fallback to types/files.py if mimetypes doesn't return valid extensions\n        #################\n        # litellm runs on docker containers and `mimetypes` depends on the installed mimetypes of the OS\n        # we fallback to well known mime types in types/files.py if mimetypes doesn't return valid extensions\n        if not valid_extensions:\n            try:\n                fallback_extension: Final = get_file_extension_from_mime_type(mime_type)\n                if fallback_extension in supported_doc_formats:\n                    valid_extensions = [fallback_extension]\n            except ValueError:\n                # Neither mimetypes nor files.py could handle this MIME type\n                # get_file_extension_from_mime_type raises ValueError if the mime type is not supported\n                pass\n\n        if not valid_extensions:\n            raise ValueError(\n                f\"No supported extensions for MIME type: {mime_type}. Supported formats: {supported_doc_formats}\"\n            )\n\n        # Use first valid extension instead of provided image_format\n        return valid_extensions[0]\n\n    @staticmethod\n    def _create_bedrock_block(image_bytes: str, mime_type: str, image_format: str) -> BedrockContentBlock:\n        \"\"\"Create appropriate Bedrock content block based on mime type.\"\"\"\n        _blob: Final = BedrockSourceBlock(bytes=image_bytes)\n\n        document_types: Final = [\"application\", \"text\"]\n        is_document: Final = any(mime_type.startswith(doc_type) for doc_type in document_types)\n\n        supported_video_formats: Final = litellm.AmazonConverseConfig().get_supported_video_types()\n        is_video: Final = any(image_format.startswith(video_type) for video_type in supported_video_formats)\n\n        HASH_SAMPLE_BYTES: Final = 64 * 1024  # hash up to 64 KB of data","sourceCodeStart":3498,"sourceCodeEnd":3534,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/prompt_templates/factory.py#L3498-L3534","documentation":"Bedrock document handling: given a mime_type, LiteLLM tries mimetypes.guess_all_extensions and falls back to its own mime-to-extension table, keeping only extensions in the supported document formats list. If both yield nothing usable, this ValueError is raised — the document's MIME type has no Bedrock-supported extension.","triggerScenarios":"Sending a document with an unsupported mime type (e.g. application/x-zip-compressed, application/msword legacy, text/csv variants, proprietary types) to a Bedrock model via the document path; mislabelled content-type on stored files.","commonSituations":"Uploading DOC/XLS/ZIP/etc. files when only PDF/DOCX/TXT/MD-style document types are supported; files whose extension was stripped so only a weird mime header remains; CSV/TSV sent where a text/* type is accepted only for specific extensions.","solutions":["Convert the document to a supported type (typically PDF or plain text) before sending","Fix the mime_type/extension on the file so it maps to a supported document format (check the error's supported list)","For data files, extract the text and send it as text content instead of a document block"],"exampleFix":"# before\nblock = {\"type\": \"file\", \"file\": {\"filename\": \"data.zip\", \"file_data\": \"data:application/zip;base64,<b64>\"}}\n\n# after: convert content to PDF/text first\nimport subprocess\nsubprocess.run([\"libreoffice\", \"--headless\", \"--convert-to\", \"pdf\", \"report.doc\"], check=True)\nblock = {\"type\": \"file\", \"file\": {\"filename\": \"report.pdf\", \"file_data\": \"data:application/pdf;base64,<b64>\"}}","handlingStrategy":"validation","validationCode":"import mimetypes\n\nSUPPORTED_DOC_EXTENSIONS = {\"pdf\", \"doc\", \"docx\", \"xls\", \"xlsx\", \"csv\", \"md\", \"txt\"}  # align with error's list\n\ndef validate_bedrock_document(filename: str, mime_type: str) -> None:\n    exts = {e.lstrip(\".\").lower() for e in mimetypes.guess_all_extensions(mime_type)}\n    if not (exts & SUPPORTED_DOC_EXTENSIONS):\n        raise ValueError(f\"convert {mime_type} to a supported document type (e.g. PDF) before sending\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Convert documents to PDF before sending to Bedrock","Keep filenames/extensions aligned with real content types","Send tabular data as text instead of a document block"],"tags":["bedrock","documents","mime-type","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}