wavetermdev/waveterm · error
dropping file with unsupported media type '%s' (must be uplo
Error message
dropping file with unsupported media type '%s' (must be uploaded to Files API and sent as file_id)
What it means
The Anthropic converter only supports image/*, application/pdf, and text/plain media types for inline conversion. Any other media type (audio, video, zip, office docs, etc.) cannot be sent inline and must be uploaded to Anthropic's Files API and referenced by file_id, so the library rejects the part with this error rather than silently producing a bad block.
Source
Thrown at pkg/aiusechat/anthropic/anthropic-convertmessage.go:454
if err != nil {
return nil, fmt.Errorf("failed to decode base64 data: %w", err)
}
return &anthropicMessageContentBlock{
Type: "document",
Source: &anthropicSource{
Type: "text",
Data: string(textData),
MediaType: "text/plain",
},
}, nil
} else {
// HTTP/HTTPS URL → not supported inline, would need to fetch
return nil, fmt.Errorf("dropping text/plain file with URL (must be fetched and converted to base64 or uploaded to Files API)")
}
default:
// Other media types → not supported inline, must upload and use file_id
return nil, fmt.Errorf("dropping file with unsupported media type '%s' (must be uploaded to Files API and sent as file_id)", p.MediaType)
}
}
// convertAIMessageToAnthropicChatMessage converts an AIMessage to anthropicChatMessage
// These messages are ALWAYS role "user"
func ConvertAIMessageToAnthropicChatMessage(aiMsg uctypes.AIMessage) (*anthropicChatMessage, error) {
if err := aiMsg.Validate(); err != nil {
return nil, fmt.Errorf("invalid AIMessage: %w", err)
}
var contentBlocks []anthropicMessageContentBlock
for i, part := range aiMsg.Parts {
switch part.Type {
case uctypes.AIMessagePartTypeText:
if part.Text == "" {
return nil, fmt.Errorf("part %d: text type requires non-empty text field", i)View on GitHub (pinned to a4447c1563)
Solutions
- Upload the file to the Anthropic Files API and reference it via file_id in your request
- Restrict accepted attachments to images, PDFs, and text before they reach the converter
- Transcode non-image media into a supported representation (e.g. transcribe audio to text, convert docs to PDF/text)
Example fix
// before
part := uctypes.UIMessagePart{Type: "file", MediaType: "audio/mpeg", URL: dataURL}
// after
// transcribe or convert first
part := uctypes.UIMessagePart{Type: "file", MediaType: "text/plain", URL: "data:text/plain;base64," + base64.StdEncoding.EncodeToString(transcript)} Defensive patterns
Strategy: validation
Validate before calling
func inlineSupported(mime string) bool {
return strings.HasPrefix(mime, "image/") || mime == "application/pdf" || mime == "text/plain"
}
if !inlineSupported(p.MediaType) { /* upload to Files API or reject */ } Type guard
func isInlineableMedia(mime string) bool {
return strings.HasPrefix(mime, "image/") || mime == "application/pdf" || mime == "text/plain"
} Try / catch
if err := convert(msg); err != nil {
if strings.Contains(err.Error(), "unsupported media type") {
fileID, uerr := uploadToAnthropicFiles(part)
if uerr == nil { return convert(withFileID(msg, fileID)) }
}
return err
} Prevention
- Whitelist accepted attachment mime types at ingestion (image/*, application/pdf, text/plain)
- Implement a Files API upload path for everything else
- Convert/transcode audio, video, and office docs into supported formats before sending
When it happens
Trigger: Sending a UIMessagePart or AIMessagePart with Type "file" whose MediaType is e.g. audio/mpeg, video/mp4, application/zip, application/vnd.openxmlformats-officedocument.wordprocessingml.document — anything not image/*, application/pdf, or text/plain.
Common situations: Attaching audio/video recordings from a chat UI; sending Excel/Word/CSV(odd mime) attachments; forwarding arbitrary user uploads straight to the model without filtering.
Related errors
- unsupported media type '%s' (must be uploaded to Files API a
- convertFileUIMessagePart expects 'file' type, got '%s'
- unsupported URL protocol in file part: %s
- failed to decode base64 data: %w
- dropping text/plain file with URL (must be fetched and conve
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/d4bf2b2a295ce234.
Report an issue: GitHub.