chenhg5/cc-connect · warning
%s is not an image (detected mime: %s)
Error message
%s is not an image (detected mime: %s)
What it means
loadImageAttachments sniffs each file's MIME type via readAttachment and only accepts types starting with "image/". A file whose detected content type is not an image (e.g. text/plain, application/pdf) produces "%s is not an image (detected mime: %s)". Detection is content-based, so a wrong extension does not bypass the check.
Source
Thrown at cmd/cc-connect/send.go:226
req.Audios = audioFiles
req.Videos = videoFiles
if req.Message == "" && req.TTSText == "" && len(req.Images) == 0 && len(req.Files) == 0 && len(req.Audios) == 0 && len(req.Videos) == 0 {
return req, "", fmt.Errorf("message, tts text, or attachment is required")
}
return req, dataDir, nil
}
func loadImageAttachments(paths []string, maxSize int64) ([]core.ImageAttachment, error) {
images := make([]core.ImageAttachment, 0, len(paths))
for _, path := range paths {
data, fileName, mimeType, err := readAttachment(path, maxSize)
if err != nil {
return nil, err
}
if !strings.HasPrefix(mimeType, "image/") {
return nil, fmt.Errorf("%s is not an image (detected mime: %s)", path, mimeType)
}
images = append(images, core.ImageAttachment{MimeType: mimeType, Data: data, FileName: fileName})
}
return images, nil
}
func loadFileAttachments(paths []string, maxSize int64) ([]core.FileAttachment, error) {
files := make([]core.FileAttachment, 0, len(paths))
for _, path := range paths {
data, fileName, mimeType, err := readAttachment(path, maxSize)
if err != nil {
return nil, err
}
files = append(files, core.FileAttachment{MimeType: mimeType, Data: data, FileName: fileName})
}
return files, nil
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Pass an actual image (png, jpeg, gif, webp, ...) via --image.
- For non-image documents use --file instead of --image.
- Run `file <path>` to check the detected MIME type before sending.
- Re-export/re-download the image if it was saved as text/HTML by mistake.
Example fix
// before cc-connect send --image ./report.pdf // after cc-connect send --file ./report.pdf // or a real image: cc-connect send --image ./chart.png
Defensive patterns
Strategy: validation
Validate before calling
file --brief --mime-type "$IMG" | grep -q '^image/' || { echo "$IMG is not an image"; exit 1; }
cc-connect send --image "$IMG" Try / catch
out, err := cmd.CombinedOutput()
if err != nil && strings.Contains(string(out), "is not an image") {
log.Printf("use --file for non-image attachments: %v", err)
} Prevention
- Detect the real MIME type (file --brief --mime-type) before passing --image.
- Use --file for PDFs, text, and other documents.
- Beware of HTML error pages saved with image extensions.
- Content sniffing decides, not the file extension.
When it happens
Trigger: `cc-connect send --image notes.txt` (detected text/plain); passing a PDF, JSON, or renamed binary as --image; an HTML error page saved as .png (detected text/html).
Common situations: Wrong path/variable pointing at a non-image file; expecting --image to accept PDFs (use --file instead); a failed download left an HTML/text blob with an image extension.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- %s is not %s media (detected mime: %s)
- attachment %s exceeds size limit (%d MB)
- empty url
- empty token
- app_id/app_secret are required
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/87c111714c04e1cc.
Report an issue: GitHub.