chenhg5/cc-connect · error
log size %q: missing numeric part
Error message
log size %q: missing numeric part
What it means
ParseLogSize splits the input into a numeric part and an optional size suffix (K/KB/M/MB/G/GB/T/TB). This error is returned when after stripping a recognized suffix there is no numeric text left, e.g. the value is just a suffix like "MB".
Source
Thrown at daemon/logsize.go:71
numPart = s[:len(s)-len("M")]
case strings.HasSuffix(upper, "KB"):
multiplier = 1024
numPart = s[:len(s)-len("KB")]
case strings.HasSuffix(upper, "K"):
multiplier = 1024
numPart = s[:len(s)-len("K")]
case strings.HasSuffix(upper, "B"):
// Explicit bytes — only the bare "B" suffix (not "XB" for some X).
// The "KB"/"MB"/"GB"/"TB" cases above are tried first and win.
multiplier = 1
numPart = s[:len(s)-len("B")]
default:
numPart = s
}
numPart = strings.TrimSpace(numPart)
if numPart == "" {
return 0, fmt.Errorf("log size %q: missing numeric part", orig)
}
n, err := strconv.ParseInt(numPart, 10, 64)
if err != nil {
return 0, fmt.Errorf("log size %q: %w", orig, err)
}
if n < 0 {
return 0, fmt.Errorf("log size %q: must be non-negative", orig)
}
return n * multiplier, nil
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Include the number with the unit, e.g. "10GB" instead of "GB".
- Use a bare integer if no suffix is desired (bytes), e.g. "10737418240".
- Check the echoed original value %q in the message to spot the malformed input.
Example fix
// before log_max_size = "GB" // after log_max_size = "10GB"
Defensive patterns
Strategy: validation
Validate before calling
re := regexp.MustCompile(`^\d+\s*(K|KB|M|MB|G|GB|T|TB)?$`)
if !re.MatchString(strings.TrimSpace(cfg.LogMaxSize)) {
return fmt.Errorf("log_max_size %q must be a number with optional unit, e.g. \"100MB\"", cfg.LogMaxSize)
} Try / catch
size, err := daemon.ParseLogSize(s)
if err != nil {
if strings.Contains(err.Error(), "missing numeric part") {
return fmt.Errorf("add a number before the unit, e.g. \"10GB\"")
}
return err
} Prevention
- Always pair the unit with a number: "10GB", never "GB".
- Copy size values from documented examples rather than typing units alone.
- Pre-validate with a regex matching number + optional unit.
When it happens
Trigger: Calling ParseLogSize with inputs like "MB", "KB", "GB", or a suffix with surrounding spaces where the numeric part is empty after trimming.
Common situations: User writes log_max_size = "GB" instead of "10GB"; copy/paste dropping the number; config value edited so the digits were accidentally deleted.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- log backups %q: %w
- tmux: 'session' option is required (name of the tmux session
- config: relay.visibility must be "full", "summary", or "none
- config: at least one [[projects]] entry is required
- config: %s.name is required
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/881ca3dbad7f6173.
Report an issue: GitHub.