home-assistant/core · error · HomeAssistantError

wrong_file_type

Error message

wrong_file_type

What it means

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.

Source

Thrown at homeassistant/components/anthropic/entity.py:1290

                )

            if mime_type is None:
                mime_type = guess_file_type(file_path)[0]

            if (
                not mime_type
                or not mime_type.startswith(("image/", "application/pdf"))
                or not model_info.capabilities
                or (
                    mime_type.startswith("image/")
                    and not model_info.capabilities.image_input.supported
                )
                or (
                    mime_type.startswith("application/pdf")
                    and not model_info.capabilities.pdf_input.supported
                )
            ):
                raise HomeAssistantError(
                    translation_domain=DOMAIN,
                    translation_key="wrong_file_type",
                    translation_placeholders={
                        "file_path": file_path.as_posix(),
                        "mime_type": mime_type or "unknown",
                        "model": model_info.display_name,
                    },
                )
            if mime_type == "image/jpg":
                mime_type = "image/jpeg"

            base64_file = base64.b64encode(file_path.read_bytes()).decode("utf-8")

            if mime_type.startswith("image/"):
                content.append(
                    ImageBlockParam(
                        type="image",
                        source=Base64ImageSourceParam(

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Switch the integration's chat model to one whose capabilities include image and/or PDF input (placeholders show the current model)
  2. Convert the attachment to a supported type (JPEG/PNG image or PDF) before attaching
  3. Give files correct extensions so MIME guessing works
Defensive patterns

Strategy: validation

Validate before calling

from mimetypes import guess_file_type

def file_sendable(file_path, mime_type, model_info) -> bool:
    mime = mime_type or guess_file_type(file_path)[0]
    if not mime:
        return False
    if not mime.startswith(("image/", "application/pdf")):
        return False
    caps = model_info.capabilities
    if mime.startswith("image/") and not caps.image_input.supported:
        return False
    if mime.startswith("application/pdf") and not caps.pdf_input.supported:
        return False
    return True

Try / catch

if (
    not mime_type
    or not mime_type.startswith(("image/", "application/pdf"))
    or not model_info.capabilities
    or (mime_type.startswith("image/") and not model_info.capabilities.image_input.supported)
    or (mime_type.startswith("application/pdf") and not model_info.capabilities.pdf_input.supported)
):
    raise HomeAssistantError(translation_domain=DOMAIN, translation_key="wrong_file_type", ...)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/c69130d6adbb95b9. Report an issue: GitHub.