{"record":{"id":"87c111714c04e1cc","repo":"chenhg5/cc-connect","slug":"s-is-not-an-image-detected-mime-s","errorCode":null,"errorMessage":"%s is not an image (detected mime: %s)","messagePattern":"(.+?) is not an image \\(detected mime: (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/cc-connect/send.go","lineNumber":226,"sourceCode":"\treq.Audios = audioFiles\n\treq.Videos = videoFiles\n\n\tif req.Message == \"\" && req.TTSText == \"\" && len(req.Images) == 0 && len(req.Files) == 0 && len(req.Audios) == 0 && len(req.Videos) == 0 {\n\t\treturn req, \"\", fmt.Errorf(\"message, tts text, or attachment is required\")\n\t}\n\n\treturn req, dataDir, nil\n}\n\nfunc loadImageAttachments(paths []string, maxSize int64) ([]core.ImageAttachment, error) {\n\timages := make([]core.ImageAttachment, 0, len(paths))\n\tfor _, path := range paths {\n\t\tdata, fileName, mimeType, err := readAttachment(path, maxSize)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !strings.HasPrefix(mimeType, \"image/\") {\n\t\t\treturn nil, fmt.Errorf(\"%s is not an image (detected mime: %s)\", path, mimeType)\n\t\t}\n\t\timages = append(images, core.ImageAttachment{MimeType: mimeType, Data: data, FileName: fileName})\n\t}\n\treturn images, nil\n}\n\nfunc loadFileAttachments(paths []string, maxSize int64) ([]core.FileAttachment, error) {\n\tfiles := make([]core.FileAttachment, 0, len(paths))\n\tfor _, path := range paths {\n\t\tdata, fileName, mimeType, err := readAttachment(path, maxSize)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfiles = append(files, core.FileAttachment{MimeType: mimeType, Data: data, FileName: fileName})\n\t}\n\treturn files, nil\n}\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/send.go#L208-L244","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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."],"exampleFix":"// before\ncc-connect send --image ./report.pdf\n// after\ncc-connect send --file ./report.pdf\n// or a real image:\ncc-connect send --image ./chart.png","handlingStrategy":"validation","validationCode":"file --brief --mime-type \"$IMG\" | grep -q '^image/' || { echo \"$IMG is not an image\"; exit 1; }\ncc-connect send --image \"$IMG\"","typeGuard":null,"tryCatchPattern":"out, err := cmd.CombinedOutput()\nif err != nil && strings.Contains(string(out), \"is not an image\") {\n    log.Printf(\"use --file for non-image attachments: %v\", err)\n}","preventionTips":["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."],"tags":["attachments","validation","file-type"],"backgroundTag":"invalid-argument-value","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}