wavetermdev/waveterm · error
dropping file with unsupported mimetype '%s' (OpenAI support
Error message
dropping file with unsupported mimetype '%s' (OpenAI supports images, PDFs, text/plain, and directories)
What it means
The OpenAI backend only supports file parts with mimetypes: images (image/*), application/pdf, text/plain, and 'directory' listings. Any other mimetype hits the default case and the part is rejected with this error listing the supported set. Unlike the others, this is an unsupported-feature error — the part must be converted or dropped by the caller.
Source
Thrown at pkg/aiusechat/openai/openai-convertmessage.go:393
}, nil
case part.MimeType == "directory":
var jsonContent string
if len(part.Data) > 0 {
jsonContent = string(part.Data)
} else {
return nil, fmt.Errorf("directory listing part missing data")
}
formattedText := aiutil.FormatAttachedDirectoryListing(part.FileName, jsonContent)
return &OpenAIMessageContent{
Type: "input_text",
Text: formattedText,
}, nil
default:
return nil, fmt.Errorf("dropping file with unsupported mimetype '%s' (OpenAI supports images, PDFs, text/plain, and directories)", part.MimeType)
}
}
// ConvertAIMessageToOpenAIChatMessage converts an AIMessage to OpenAIChatMessage
// These messages are ALWAYS role "user"
// Handles text parts, images, PDFs, and text/plain files
func ConvertAIMessageToOpenAIChatMessage(aiMsg uctypes.AIMessage) (*OpenAIChatMessage, error) {
if err := aiMsg.Validate(); err != nil {
return nil, fmt.Errorf("invalid AIMessage: %w", err)
}
var contentBlocks []OpenAIMessageContent
imageCount := 0
imageFailCount := 0
for i, part := range aiMsg.Parts {
switch part.Type {
case uctypes.AIMessagePartTypeText:View on GitHub (pinned to a4447c1563)
Solutions
- Convert unsupported files to text/plain or a supported format before attaching (e.g. extract text from .docx/.csv)
- Read the file and attach as text/plain content when it's fundamentally textual
- Skip unsupported parts with a user-visible notice instead of failing the whole request
- Check the mimetype against the supported list (image/*, application/pdf, text/plain, directory) before adding the part
Example fix
// before
part := uctypes.AIMessagePart{Type: "file", MimeType: "text/csv", Data: csvBytes} // unsupported
// after
part := uctypes.AIMessagePart{Type: "file", MimeType: "text/plain", FileName: "data.csv", Data: csvBytes} // send as plain text Defensive patterns
Strategy: validation
Validate before calling
var supportedPDFImage = func(mt string) bool {
return strings.HasPrefix(mt, "image/") || mt == "application/pdf" ||
mt == "text/plain" || mt == "directory"
}
// drop or convert parts where !supportedPDFImage(part.MimeType) before sending Type guard
func isOpenAISupportedFile(p uctypes.AIMessagePart) bool {
if p.Type != uctypes.AIMessagePartTypeFile { return false }
return strings.HasPrefix(p.MimeType, "image/") || p.MimeType == "application/pdf" ||
p.MimeType == "text/plain" || p.MimeType == "directory"
} Prevention
- Normalize or extract text from docx/csv/xlsx before attaching
- Maintain a supported-mimetype allowlist in your attachment pipeline
- Surface a user-facing notice when a part is dropped/converted
When it happens
Trigger: Attaching files like .docx, .xlsx, .csv, application/json, image-less binaries, or audio/video parts to a message sent through the OpenAI backend; a generic file-attachment pipeline passing arbitrary mimetypes through unfiltered.
Common situations: Users attaching Office documents or spreadsheets in a chat UI; CSV/JSON data files attached as-is; feature parity gaps when switching backends (e.g. Anthropic accepts more types than this OpenAI path).
Related errors
- convertFileAIMessagePart expects 'file' type, got '%s'
- file part missing mimetype
- dropping PDF with URL (must be fetched and converted to base
- PDF file part missing data
- directory listing part missing data
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/bd58823bf33ae9b6.
Report an issue: GitHub.