chenhg5/cc-connect · error
%s is not %s media (detected mime: %s)
Error message
%s is not %s media (detected mime: %s)
What it means
loadTypedFileAttachments verifies that every attachment supplied via `cc-connect send --media-type <type>` actually matches the requested media type. It compares the mime type detected from the file content/filename (via detectAttachmentMimeType) against the requested mediaType using attachmentMatchesMediaType; on mismatch it refuses the file rather than sending a wrongly-typed attachment to the platform. This prevents e.g. an image agent API from receiving a PDF that was passed by mistake.
Source
Thrown at cmd/cc-connect/send.go:253
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
}
func loadTypedFileAttachments(paths []string, mediaType 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
}
if !attachmentMatchesMediaType(mimeType, fileName, mediaType) {
return nil, fmt.Errorf("%s is not %s media (detected mime: %s)", path, mediaType, mimeType)
}
files = append(files, core.FileAttachment{MimeType: mimeType, Data: data, FileName: fileName})
}
return files, nil
}
func attachmentMatchesMediaType(mimeType, fileName, mediaType string) bool {
ext := strings.ToLower(filepath.Ext(fileName))
switch mediaType {
case "audio":
if strings.HasPrefix(mimeType, "audio/") {
return true
}
switch ext {
case ".aac", ".flac", ".m4a", ".mp3", ".oga", ".ogg", ".opus", ".wav":
return true
}
case "video":View on GitHub (pinned to 4000b2338a)
Solutions
- Check the detected mime in the error message and replace the offending path with a file that matches the requested media type
- Drop --media-type so the file is loaded as a generic file attachment (loadFileAttachments) instead of typed media
- Fix the file extension if the content is actually of the requested type but named wrongly, so mime detection classifies it correctly
Example fix
// before cc-connect send --media-type image ./assets/* // after cc-connect send --media-type image ./assets/photo.png ./assets/diagram.jpg
Defensive patterns
Strategy: validation
Validate before calling
file="./assets/photo.png"; file "$file" # verify mime matches --media-type before running send
Prevention
- Use explicit file paths instead of loose globs
- Check `file <path>` output when unsure of real content type
- Prefer generic file attachments when type filtering is not needed
When it happens
Trigger: Running `cc-connect send ... --media-type image` (or similar) while one of the given paths is a non-image file (e.g. a .txt, .pdf, or .mp4), so detectAttachmentMimeType returns a mime that does not satisfy attachmentMatchesMediaType for the requested type.
Common situations: Passing a glob that picks up non-matching files (e.g. `./assets/*` picking up a README), renaming a file with an image extension when it is actually another format, or confusing image vs file attachments on the send command.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- attachment %s exceeds size limit (%d MB)
- %s must be true or false
- timeout_mins must be an integer
- invalid value for --log-max-size: %s
- invalid --platform-type %q, want feishu or lark
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/86e1abb08747cae2.
Report an issue: GitHub.