{"record":{"id":"e00ca56f6b316e8d","repo":"crewAIInc/crewAI","slug":"file-type-format-content-type-is-not-support","errorCode":null,"errorMessage":"{file_type} format '{content_type}' is not supported. Supported: {', '.join(supported_formats)}","messagePattern":"(.+?) format '(.+?)' is not supported\\. Supported: (.+?)","errorType":"validation","errorClass":"UnsupportedFileTypeError","httpStatus":null,"severity":"error","filePath":"lib/crewai-files/src/crewai_files/processing/validators.py","lineNumber":219,"sourceCode":") -> None:\n    \"\"\"Validate content type against supported formats.\n\n    Args:\n        file_type: Type label for error messages (e.g., \"Image\", \"Audio\").\n        filename: Name of the file being validated.\n        content_type: MIME type of the file.\n        supported_formats: Tuple of supported MIME types.\n        errors: List to append error messages to.\n        raise_on_error: If True, raise UnsupportedFileTypeError on failure.\n    \"\"\"\n    if content_type not in supported_formats:\n        msg = (\n            f\"{file_type} format '{content_type}' is not supported. \"\n            f\"Supported: {', '.join(supported_formats)}\"\n        )\n        errors.append(msg)\n        if raise_on_error:\n            raise UnsupportedFileTypeError(\n                msg, file_name=filename, content_type=content_type\n            )\n\n\ndef validate_image(\n    file: ImageFile,\n    constraints: ImageConstraints,\n    *,\n    raise_on_error: bool = True,\n) -> Sequence[str]:\n    \"\"\"Validate an image file against constraints.\n\n    Args:\n        file: The image file to validate.\n        constraints: Image constraints to validate against.\n        raise_on_error: If True, raise exceptions on validation failure.\n\n    Returns:","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-files/src/crewai_files/processing/validators.py#L201-L237","documentation":"_validate_format raises UnsupportedFileTypeError when the file's content_type is not in the supported_formats tuple of the constraints (e.g. ImageConstraints accepting only certain image MIME types). The exception carries file_name and content_type fields, and the message lists the supported set. It guards against MIME types the target provider cannot ingest.","triggerScenarios":"Validating a file whose content_type (e.g. image/webp, image/heic, application/msword) is not listed in the constraints' supported formats, with raise_on_error=True. Typical when supported_formats is narrowed to ('image/jpeg', 'image/png') but the user uploads HEIC from an iPhone.","commonSituations":"iPhone HEIC/HEIF photos rejected by JPEG/PNG-only constraints; WebP from modern tools rejected by older allowlists; constraints tuples written for one provider reused for another with a different supported set; spoofed or mis-detected MIME types (a .png actually served as application/octet-stream).","solutions":["Add the actual MIME type to supported_formats in the constraints if the provider supports it (e.g. add 'image/webp').","Convert the file upstream to a supported format (HEIC → JPEG) before validation.","Detect the real content type from bytes (e.g. python-magic) instead of trusting the declared one.","Catch UnsupportedFileTypeError and read e.content_type to produce a clear user-facing message."],"exampleFix":"# before\nconstraints = ImageConstraints(supported_formats=(\"image/jpeg\", \"image/png\"))\nvalidate_image(heic_img, constraints)  # UnsupportedFileTypeError: image/heic\n\n# after\nconstraints = ImageConstraints(supported_formats=(\"image/jpeg\", \"image/png\", \"image/heic\", \"image/webp\"))\n# or convert upstream:\n# heic_img = convert_to_jpeg(heic_img)","handlingStrategy":"validation","validationCode":"if file.content_type not in constraints.supported_formats:\n    return reject(f\"format {file.content_type} not in {constraints.supported_formats}\")","typeGuard":"def is_supported_format(content_type: str, supported: tuple[str, ...]) -> TypeGuard[str]:\n    return content_type in supported","tryCatchPattern":"from crewai_files.processing.exceptions import UnsupportedFileTypeError\n\ntry:\n    processor.process(file)\nexcept UnsupportedFileTypeError as e:\n    return reject(f\"'{e.file_name}': type {e.content_type} not supported; convert or extend supported_formats\")","preventionTips":["Detect the real MIME type from bytes (python-magic) instead of trusting the declared one.","Keep the supported_formats tuple in one place and align it with the provider's documented list.","Convert HEIC/WebP/office formats upstream to the accepted set."],"tags":["validation","mime-type","content-type","constraints","unsupportedfiletypeerror"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}