chenhg5/cc-connect · error
invalid --max-bytes %q
Error message
invalid --max-bytes %q
What it means
--max-bytes must parse as an integer via fmt.Sscanf("%d"); a non-numeric value triggers this error in parseTuiTuiArgs. The parsed value bounds downloadTuiTuiURL's download size check (errors 441/442).
Source
Thrown at cmd/cc-connect/tuitui.go:338
case "--url":
v, err := value()
if err != nil {
return opts, err
}
opts.url = v
case "--out":
v, err := value()
if err != nil {
return opts, err
}
opts.outDir = v
case "--max-bytes":
v, err := value()
if err != nil {
return opts, err
}
if _, err := fmt.Sscanf(v, "%d", &opts.maxBytes); err != nil {
return opts, fmt.Errorf("invalid --max-bytes %q", v)
}
case "--channel", "--channel-id":
v, err := value()
if err != nil {
return opts, err
}
opts.channelID = v
case "--parent", "--parent-id":
v, err := value()
if err != nil {
return opts, err
}
opts.parentID = v
case "--message", "-m":
v, err := value()
if err != nil {
return opts, err
}View on GitHub (pinned to 4000b2338a)
Solutions
- Use raw byte count: --max-bytes 26214400
- Convert MB to bytes (25MiB = 26214400)
- Omit the flag to use the built-in 25MiB default
Example fix
// before cc-connect tuitui download --url ... --max-bytes 50MB // after cc-connect tuitui download --url ... --max-bytes 52428800
Defensive patterns
Strategy: validation
Validate before calling
if n, err := strconv.Atoi(v); err != nil || n <= 0 {
return fmt.Errorf("invalid --max-bytes %q (want integer bytes)", v)
} Try / catch
if _, err := parseTuiTuiArgs(args); err != nil {
if strings.HasPrefix(err.Error(), "invalid --max-bytes") {
fmt.Fprintf(os.Stderr, "--max-bytes takes raw bytes, e.g. 26214400\n")
}
} Prevention
- Convert MB/GB to raw bytes before passing
- Omit the flag to use the 25MiB default
- Use strict strconv parsing in scripts that build the command
When it happens
Trigger: `--max-bytes 25MB`, `--max-bytes 1e6`, or any non-integer token passed to the tuitui download/post/messages subcommands.
Common situations: Human-readable sizes like "10MB" used instead of raw bytes; scientific notation; stray units.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- invalid --limit %q
- %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/e263746e0a26bbe5.
Report an issue: GitHub.