{"record":{"id":"c69130d6adbb95b9","repo":"home-assistant/core","slug":"wrong-file-type","errorCode":null,"errorMessage":"wrong_file_type","messagePattern":"wrong_file_type","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/anthropic/entity.py","lineNumber":1290,"sourceCode":"                )\n\n            if mime_type is None:\n                mime_type = guess_file_type(file_path)[0]\n\n            if (\n                not mime_type\n                or not mime_type.startswith((\"image/\", \"application/pdf\"))\n                or not model_info.capabilities\n                or (\n                    mime_type.startswith(\"image/\")\n                    and not model_info.capabilities.image_input.supported\n                )\n                or (\n                    mime_type.startswith(\"application/pdf\")\n                    and not model_info.capabilities.pdf_input.supported\n                )\n            ):\n                raise HomeAssistantError(\n                    translation_domain=DOMAIN,\n                    translation_key=\"wrong_file_type\",\n                    translation_placeholders={\n                        \"file_path\": file_path.as_posix(),\n                        \"mime_type\": mime_type or \"unknown\",\n                        \"model\": model_info.display_name,\n                    },\n                )\n            if mime_type == \"image/jpg\":\n                mime_type = \"image/jpeg\"\n\n            base64_file = base64.b64encode(file_path.read_bytes()).decode(\"utf-8\")\n\n            if mime_type.startswith(\"image/\"):\n                content.append(\n                    ImageBlockParam(\n                        type=\"image\",\n                        source=Base64ImageSourceParam(","sourceCodeStart":1272,"sourceCodeEnd":1308,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/anthropic/entity.py#L1272-L1308","documentation":"A HomeAssistantError with translation key 'wrong_file_type' raised when an attachment's resolved MIME type cannot be sent: it is empty, not image/* or application/pdf, or the selected model lacks the capability (image_input.supported / pdf_input.supported) for that type. Placeholders carry file_path, mime_type (or 'unknown'), and the model display name.","triggerScenarios":"mime_type is None and guess_file_type finds nothing recognizable; the file is e.g. video/mp4 or text/plain; or sending an image/PDF to a model whose ModelInfo capabilities do not include image_input or pdf_input.","commonSituations":"Users attach documents or media to a conversation agent backed by a text-only or visionless model; files without extensions giving no guessable type; model capabilities metadata outdated.","solutions":["Switch the integration's chat model to one whose capabilities include image and/or PDF input (placeholders show the current model)","Convert the attachment to a supported type (JPEG/PNG image or PDF) before attaching","Give files correct extensions so MIME guessing works"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from mimetypes import guess_file_type\n\ndef file_sendable(file_path, mime_type, model_info) -> bool:\n    mime = mime_type or guess_file_type(file_path)[0]\n    if not mime:\n        return False\n    if not mime.startswith((\"image/\", \"application/pdf\")):\n        return False\n    caps = model_info.capabilities\n    if mime.startswith(\"image/\") and not caps.image_input.supported:\n        return False\n    if mime.startswith(\"application/pdf\") and not caps.pdf_input.supported:\n        return False\n    return True","typeGuard":null,"tryCatchPattern":"if (\n    not mime_type\n    or not mime_type.startswith((\"image/\", \"application/pdf\"))\n    or not model_info.capabilities\n    or (mime_type.startswith(\"image/\") and not model_info.capabilities.image_input.supported)\n    or (mime_type.startswith(\"application/pdf\") and not model_info.capabilities.pdf_input.supported)\n):\n    raise HomeAssistantError(translation_domain=DOMAIN, translation_key=\"wrong_file_type\", ...)","preventionTips":["Choose a vision+PDF capable model when attachments are expected","Normalize attachments to JPEG/PNG/PDF with correct extensions before sending"],"tags":["home-assistant","anthropic","attachments","mime-type","model-capabilities"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}