chenhg5/cc-connect · error
log size %q: %w
Error message
log size %q: %w
What it means
ParseLogSize parses the numeric portion with strconv.ParseInt and wraps any parse failure with the original input. This error is returned when the numeric part is present but not a valid 64-bit integer (e.g. contains a decimal point, hex digits, or stray characters).
Source
Thrown at daemon/logsize.go:76
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
- Use an integer value: write "1536MB" instead of "1.5GB".
- Remove separators/spaces inside the number: "10000MB" not "10,000 MB".
- Inspect the wrapped strconv error to identify the offending character.
Example fix
// before log_max_size = "1.5GB" // after log_max_size = "1536MB"
Defensive patterns
Strategy: validation
Validate before calling
num := regexp.MustCompile(`^\d+$`)
if !num.MatchString(strings.TrimRight(strings.TrimSpace(cfg.LogMaxSize), "KMGTB")) {
return fmt.Errorf("log_max_size numeric part must be a plain integer")
} Try / catch
size, err := daemon.ParseLogSize(s)
if err != nil {
var numErr *strconv.NumError
if errors.As(err, &numErr) {
return fmt.Errorf("%q is not a valid integer size; decimals like 1.5GB are unsupported", s)
}
return err
} Prevention
- Avoid decimal sizes (1.5GB); express them as integers (1536MB).
- Strip thousands separators before passing the value.
- Beware pasted NBSP/Unicode spaces; normalize whitespace first.
When it happens
Trigger: Calling ParseLogSize with values like "1.5GB", "0x10M", "10 MB" (inner space left in numeric part), or "10,000MB".
Common situations: Decimal sizes like "1.5GB" which the parser does not support; thousands separators; Unicode spaces or NBSP pasted from docs; leading + sign.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- log backups %q: %w
- log size %q: missing numeric part
- cron project not found
- attachment send is disabled by config
- VerifyRunAsUserCheap: runAsUser is empty
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/6d0bfb6d845cf8da.
Report an issue: GitHub.