siyuan-note/siyuan · error
image MIME type is missing
Error message
image MIME type is missing
What it means
resolveAgentAttachment requires a MIME type whenever raw attachment Data is present, because the data cannot be turned into a valid image content part for the model without knowing its type. A missing MIMEType with non-empty Data produces this error.
Source
Thrown at kernel/agent/attachments.go:146
if imageCount == 0 {
return openai.ChatCompletionMessage{}, false
}
if omitted {
parts = append(parts, openai.ChatMessagePart{
Type: openai.ChatMessagePartTypeText,
Text: "One or more image attachments were omitted because they were unavailable or exceeded the request limit.",
})
}
return openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
MultiContent: parts,
}, true
}
func resolveAgentAttachment(attachment AgentAttachment) (data []byte, mimeType string, width, height int, err error) {
if len(attachment.Data) > 0 {
if attachment.MIMEType == "" {
err = fmt.Errorf("image MIME type is missing")
return
}
data = attachment.Data
mimeType = attachment.MIMEType
width = attachment.Width
height = attachment.Height
return
}
var prepared kernelModel.PreparedDocumentImage
var prepareErr error
if attachment.DocumentID == "" {
prepared, prepareErr = kernelModel.PrepareAgentMessageImage(attachment.Path)
} else {
prepared, prepareErr = kernelModel.PrepareDocumentImage(attachment.DocumentID, attachment.Path)
}
if prepareErr != nil {
err = prepareErr
returnView on GitHub (pinned to 8641553a1f)
Solutions
- Set MIMEType (e.g. "image/png") on every attachment that carries Data
- Detect the MIME type from the file signature or the source paste event before sending
- Default missing MIME types to "image/png" at the attachment-production site if that matches the data
- Validate attachments in the frontend before posting them to the agent
Example fix
// before
attach := AgentAttachment{Data: pngBytes}
// after
attach := AgentAttachment{Data: pngBytes, MIMEType: "image/png"} Defensive patterns
Strategy: validation
Validate before calling
function isValidAttachment(a) {
return !(a.data && a.data.length > 0) || Boolean(a.mimeType)
} Type guard
function hasMIME(a) { return typeof a.MIMEType === "string" && a.MIMEType !== "" } Prevention
- Always populate MIMEType when constructing AgentAttachment values
- Detect MIME from magic bytes at paste/import time
- Add a constructor/helper that rejects attachments without a MIME type
When it happens
Trigger: buildAttachmentMessage calls resolveAgentAttachment with an AgentAttachment whose Data is non-empty but MIMEType is "" — the named-return err is set and the attachment resolution aborts.
Common situations: Frontend or plugin builds AgentAttachment structs manually and forgets MIMEType; attachments deserialized from older/external payloads that omit the MIME field; clipboard pastes where the MIME type was not detected.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- image attachment request limit exceeded: at most %d images a
- invalid frontend capability ID: %s
- frontend capability description is required: %s
- invalid frontend capability [%s]: %w
- invalid agent permission mode
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/8d79b460ae0d1961.
Report an issue: GitHub.