spring-projects/spring-ai · error · java.lang.IllegalArgumentException
Unsupported video format:
Error message
Unsupported video format:
What it means
BedrockMediaFormat.getVideoFormat() looks up the MimeType in VIDEO_MAP, mapping to Bedrock Converse VideoFormat values. If absent, an IllegalArgumentException is thrown because the video mime type is not supported by the Bedrock Converse API.
Source
Thrown at models/spring-ai-bedrock-converse/src/main/java/org/springframework/ai/bedrock/converse/api/BedrockMediaFormat.java:132
return IMAGE_MAP.containsKey(mimeType);
}
public static ImageFormat getImageFormat(MimeType mimeType) {
ImageFormat format = IMAGE_MAP.get(mimeType);
if (format == null) {
throw new IllegalArgumentException("Unsupported image format: " + mimeType);
}
return format;
}
public static Boolean isSupportedVideoFormat(MimeType mimeType) {
return VIDEO_MAP.containsKey(mimeType);
}
public static VideoFormat getVideoFormat(MimeType mimeType) {
VideoFormat format = VIDEO_MAP.get(mimeType);
if (format == null) {
throw new IllegalArgumentException("Unsupported video format: " + mimeType);
}
return format;
}
}
View on GitHub (pinned to 98a7beda4f)
Solutions
- Transcode the video to a supported Bedrock format (mp4, mov, mkv where mapped) and set the matching MimeType.
- Pre-check with isSupportedVideoFormat before constructing the prompt.
- Ensure the Media mimeType is explicitly set to a supported value.
- Consult AWS Bedrock Converse docs for the up-to-date list of supported video formats.
Example fix
// before
new Media(MimeType.valueOf("video/avi"), aviResource);
// after
new Media(MimeType.valueOf("video/mp4"), mp4Resource); Defensive patterns
Strategy: validation
Validate before calling
if (!BedrockMediaFormat.isSupportedVideoFormat(media.getMimeType())) {
throw new IllegalArgumentException("Video format not supported by Bedrock: " + media.getMimeType());
} Type guard
boolean isSupportedVideo(MimeType mt) {
return mt != null && BedrockMediaFormat.isSupportedVideoFormat(mt);
} Try / catch
try {
String fmt = BedrockMediaFormat.getFormatAsString(media);
} catch (IllegalArgumentException e) {
// transcode or drop the video item
} Prevention
- Transcode videos to mp4/mov before sending to Bedrock
- Pre-check with isSupportedVideoFormat
- Never rely on filename-derived mime types without verification
When it happens
Trigger: Calling getFormatAsString/getVideoFormat with a video MimeType not in VIDEO_MAP, e.g. video/avi, video/mkv, or a null/blank mimeType on a video Media item.
Common situations: Passing video files with container formats Bedrock does not accept; mime types inferred from filenames that are wrong or unusual; users expecting all video containers to work.
Related errors
- Unsupported image format:
- Unsupported media format:
- Unsupported media format:
- Unsupported document format:
- SSE connection '<connectionName>' requires a 'url' property.
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/f4bec5c5a621a891.
Report an issue: GitHub.