chenhg5/cc-connect · error
attachment %s exceeds size limit (%d MB)
Error message
attachment %s exceeds size limit (%d MB)
What it means
readAttachment enforces a maximum attachment size (maxSize in bytes, reported in MB) by stat'ing the file before reading it into memory. Files larger than the limit are rejected with this error, protecting the process from OOM and platforms from oversized uploads.
Source
Thrown at cmd/cc-connect/send.go:308
cfg, err := config.Load(resolveConfigPath(""))
if err != nil {
return nil
}
return cfg
}
// readAttachment reads a single attachment file, rejecting anything larger than
// maxSize bytes (resolved by the caller from config/env/default). The limit is
// enforced before the file is read into memory.
func readAttachment(path string, maxSize int64) ([]byte, string, string, error) {
cleaned := filepath.Clean(path)
info, err := os.Stat(cleaned)
if err != nil {
return nil, "", "", fmt.Errorf("read attachment %s: %w", path, err)
}
if info.Size() > maxSize {
return nil, "", "", fmt.Errorf("attachment %s exceeds size limit (%d MB)", path, maxSize>>20)
}
data, err := os.ReadFile(cleaned)
if err != nil {
return nil, "", "", fmt.Errorf("read attachment %s: %w", path, err)
}
fileName := filepath.Base(cleaned)
return data, fileName, detectAttachmentMimeType(fileName, data), nil
}
func detectAttachmentMimeType(fileName string, data []byte) string {
ext := strings.ToLower(filepath.Ext(fileName))
switch ext {
case ".md", ".markdown":
return "text/markdown; charset=utf-8"
}
if byExt := mime.TypeByExtension(ext); byExt != "" {
return byExtView on GitHub (pinned to 4000b2338a)
Solutions
- Remove or compress the oversized file (e.g. downscale images, zip logs) and resend
- Split the content into multiple smaller attachments
- Raise maxSize if your target platform genuinely allows larger uploads
Example fix
// before cc-connect send ./capture-full-4gb.mov // after ffmpeg -i capture-full-4gb.mov -crf 28 capture-small.mp4 && cc-connect send ./capture-small.mp4
Defensive patterns
Strategy: validation
Validate before calling
path="./capture.mov"; limit=$((30*1024*1024)); size=$(stat -c%s "$path"); [ "$size" -le "$limit" ] || { echo "too large: $size bytes" >&2; exit 1; } Prevention
- Check file sizes before attaching large media
- Compress/downscale media proactively
- Know your platform's upload cap and size files accordingly
When it happens
Trigger: Running any send command with an attachment whose on-disk size exceeds maxSize (usually the platform's upload limit, e.g. 30 MB), regardless of content type.
Common situations: Attaching large videos, raw logs, or database dumps; limit lowered by config for a platform with strict upload caps (e.g. Telegram 50 MB, Feishu smaller).
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- %s is not %s media (detected mime: %s)
- %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/54e7ad4c4f2f3c58.
Report an issue: GitHub.