{"record":{"id":"4066cf0b4dd653f8","repo":"BerriAI/litellm","slug":"bedrock-converse-only-supports-base64-encoded-docu","errorCode":null,"errorMessage":"Bedrock Converse only supports base64-encoded document sources, got '{source_type}'. Please convert the document to base64 before sending to Bedrock.","messagePattern":"Bedrock Converse only supports base64-encoded document sources, got '(.+?)'\\. Please convert the document to base64 before sending to Bedrock\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/prompt_templates/factory.py","lineNumber":4645,"sourceCode":"        if file_data is None and file_id is None:\n            raise litellm.BadRequestError(\n                message=f\"file_data and file_id cannot both be None. Got={message}\",\n                model=\"\",\n                llm_provider=\"bedrock\",\n            )\n        return await BedrockImageProcessor.process_image_async(image_url=cast(str, file_id or file_data), format=format)\n\n    @staticmethod\n    def _process_document_message(element: dict) -> BedrockContentBlock:\n        \"\"\"Convert a document content block to a Bedrock DocumentBlock.\n\n        Handles the Anthropic-style document format:\n        {\"type\": \"document\", \"source\": {\"type\": \"base64\", \"media_type\": \"application/pdf\", \"data\": \"...\"}}\n        \"\"\"\n        source: Final = element[\"source\"]\n        source_type: Final = source.get(\"type\")\n        if source_type != \"base64\":\n            raise ValueError(\n                f\"Bedrock Converse only supports base64-encoded document sources, got '{source_type}'. \"\n                \"Please convert the document to base64 before sending to Bedrock.\"\n            )\n        media_type: Final[str] = source[\"media_type\"]\n        data: Final[str] = source[\"data\"]\n        doc_format = BedrockImageProcessor._validate_format(mime_type=media_type, image_format=media_type.split(\"/\")[1])\n\n        # Deterministic name using the same hashing pattern as _create_bedrock_block\n        HASH_SAMPLE_BYTES: Final = 64 * 1024\n        normalized: Final = \"\".join(data.split()).encode(\"utf-8\")\n        sample: Final = normalized[:HASH_SAMPLE_BYTES]\n        hasher: Final = hashlib.sha256()\n        hasher.update(sample)\n        hasher.update(str(len(normalized)).encode(\"utf-8\"))\n        content_hash: Final = hasher.hexdigest()[:16]\n        document_name: Final = f\"Document_{content_hash}_{doc_format}\"\n\n        return BedrockContentBlock(","sourceCodeStart":4627,"sourceCodeEnd":4663,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/prompt_templates/factory.py#L4627-L4663","documentation":"Bedrock document handling guard: _process_document_message received a document source that is not base64-encoded (e.g. a URL or file_id); Bedrock Converse only accepts base64 document bytes, so the caller must convert first.","triggerScenarios":"Thrown at litellm/litellm_core_utils/prompt_templates/factory.py:4645 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert the document to a base64-encoded source before sending to Bedrock Converse.","Fetch URL/bytes documents and re-encode them as base64."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}