zed-industries/zed · error
unsupported image MIME type `{}`
Error message
unsupported image MIME type `{}` What it means
Validation in LanguageModelImage::from_base64_image: the supplied MIME type string is not one the `image` crate recognizes (image::ImageFormat::from_mime_type failed), so the base64 payload cannot be decoded into a model image. The image attachment's MIME type is missing, malformed, or an unsupported type (e.g. SVG or text).
Source
Thrown at crates/language_model/src/request.rs:61
ImageFormat::Webp => image::ImageFormat::WebP,
ImageFormat::Gif => image::ImageFormat::Gif,
ImageFormat::Bmp => image::ImageFormat::Bmp,
ImageFormat::Tiff => image::ImageFormat::Tiff,
ImageFormat::Ico => image::ImageFormat::Ico,
ImageFormat::Pnm => image::ImageFormat::Pnm,
ImageFormat::Svg => return None,
};
let dynamic_image =
image::load_from_memory_with_format(data.bytes(), format).log_err()?;
language_model_image_from_dynamic_image(dynamic_image)
.log_err()
.flatten()
})
}
fn from_base64_image(data: &str, mime_type: &str) -> Result<Option<LanguageModelImage>> {
let format = image::ImageFormat::from_mime_type(mime_type)
.ok_or_else(|| anyhow!("unsupported image MIME type `{}`", mime_type))?;
let bytes = base64::engine::general_purpose::STANDARD.decode(data.as_bytes())?;
let dynamic_image = image::load_from_memory_with_format(&bytes, format)?;
language_model_image_from_dynamic_image(dynamic_image)
}
}
fn language_model_image_from_dynamic_image(
dynamic_image: image::DynamicImage,
) -> Result<Option<LanguageModelImage>> {
let width = dynamic_image.width();
let height = dynamic_image.height();
let image_size = size(DevicePixels(width as i32), DevicePixels(height as i32));
// First apply any provider-specific dimension constraints we know about (Anthropic).
let mut processed_image = if image_size.width.0 > ANTHROPIC_SIZE_LIMIT as i32
|| image_size.height.0 > ANTHROPIC_SIZE_LIMIT as i32
{
let new_bounds = ObjectFit::ScaleDown.get_bounds(View on GitHub (pinned to f4178619ac)
Solutions
- Ensure the image attachment carries a standard MIME type such as image/png, image/jpeg, image/webp, or image/gif
- Strip parameters/whitespace from the MIME string if present (from_mime_type expects a bare type)
- Convert unsupported formats (e.g. SVG) to PNG before attaching
- Validate the MIME type at ingestion instead of at send time
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/language_model/src/request.rs:61 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/49e0ff95468e4f86.
Report an issue: GitHub.