crewAIInc/crewAI · error · UnsupportedFileTypeError
{file_type} format '{content_type}' is not supported. Suppor
Error message
{file_type} format '{content_type}' is not supported. Supported: {', '.join(supported_formats)} What it means
_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.
Source
Thrown at lib/crewai-files/src/crewai_files/processing/validators.py:219
) -> None:
"""Validate content type against supported formats.
Args:
file_type: Type label for error messages (e.g., "Image", "Audio").
filename: Name of the file being validated.
content_type: MIME type of the file.
supported_formats: Tuple of supported MIME types.
errors: List to append error messages to.
raise_on_error: If True, raise UnsupportedFileTypeError on failure.
"""
if content_type not in supported_formats:
msg = (
f"{file_type} format '{content_type}' is not supported. "
f"Supported: {', '.join(supported_formats)}"
)
errors.append(msg)
if raise_on_error:
raise UnsupportedFileTypeError(
msg, file_name=filename, content_type=content_type
)
def validate_image(
file: ImageFile,
constraints: ImageConstraints,
*,
raise_on_error: bool = True,
) -> Sequence[str]:
"""Validate an image file against constraints.
Args:
file: The image file to validate.
constraints: Image constraints to validate against.
raise_on_error: If True, raise exceptions on validation failure.
Returns:View on GitHub (pinned to 754d7323be)
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.
Example fix
# before
constraints = ImageConstraints(supported_formats=("image/jpeg", "image/png"))
validate_image(heic_img, constraints) # UnsupportedFileTypeError: image/heic
# after
constraints = ImageConstraints(supported_formats=("image/jpeg", "image/png", "image/heic", "image/webp"))
# or convert upstream:
# heic_img = convert_to_jpeg(heic_img) Defensive patterns
Strategy: validation
Validate before calling
if file.content_type not in constraints.supported_formats:
return reject(f"format {file.content_type} not in {constraints.supported_formats}") Type guard
def is_supported_format(content_type: str, supported: tuple[str, ...]) -> TypeGuard[str]:
return content_type in supported Try / catch
from crewai_files.processing.exceptions import UnsupportedFileTypeError
try:
processor.process(file)
except UnsupportedFileTypeError as e:
return reject(f"'{e.file_name}': type {e.content_type} not supported; convert or extend supported_formats") Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Project name '{name}' contains no valid characters for a Pyt
- "; ".join(errors)
- {file_type} '{filename}' size ({_format_size(file_size)}) ex
- Image '{filename}' width ({width}px) exceeds maximum ({const
- Image '{filename}' height ({height}px) exceeds maximum ({con
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/e00ca56f6b316e8d.
Report an issue: GitHub.