chenhg5/cc-connect · error
log backups %q: %w
Error message
log backups %q: %w
What it means
ParseLogBackups validates the log max-backups config value. This error is returned when the value is non-empty but cannot be parsed as an integer by strconv.Atoi, and the original strconv error is wrapped so the root cause is visible.
Source
Thrown at daemon/logbackups.go:30
// already an integer in any sane unit. Whitespace is trimmed.
//
// Returns an error if the input is empty, non-integer, or not >= 1. The
// minimum is 1 (one backup, the legacy behaviour); zero would mean
// "discard the previous log on every rotation", which loses the entire
// post-mortem trail at the moment something goes wrong.
//
// A typical rotation policy with N=3 and maxSize=10MB keeps cc-connect.log
// plus cc-connect.log.1 / .2 / .3 on disk, so the maximum retained footprint
// is ≈ 4 × maxSize.
func ParseLogBackups(s string) (int, error) {
orig := s
s = strings.TrimSpace(s)
if s == "" {
return 0, fmt.Errorf("log backups: empty value")
}
n, err := strconv.Atoi(s)
if err != nil {
return 0, fmt.Errorf("log backups %q: %w", orig, err)
}
if n < 1 {
return 0, fmt.Errorf("log backups %q: must be >= 1 (got %d)", orig, n)
}
return n, nil
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Set log_max_backups to a plain positive integer, e.g. "7".
- Check the wrapped strconv error in the message to see exactly why the text failed to parse (extra characters, decimal point, etc.).
- Trim whitespace/BOM from the value if it comes from an env var or external source.
Example fix
// before log_max_backups = "10x" // after log_max_backups = "10"
Defensive patterns
Strategy: validation
Validate before calling
if v := strings.TrimSpace(cfg.LogMaxBackups); v != "" {
if _, err := strconv.Atoi(v); err != nil {
return fmt.Errorf("log_max_backups must be an integer, got %q", cfg.LogMaxBackups)
}
} Try / catch
n, err := daemon.ParseLogBackups(s)
if err != nil {
var numErr *strconv.NumError
if errors.As(err, &numErr) {
// handle non-numeric input specifically
}
return err
} Prevention
- Keep log_max_backups as a bare integer in config.toml.
- Trim env-var sourced strings before passing them in.
- Add a config schema check that flags non-integer values at load time.
When it happens
Trigger: Calling ParseLogBackups (directly or via resolveLogMaxBackups during daemon install/config resolution) with a value like "three", "10x", "1.5", or a string with stray characters.
Common situations: Typo in config.toml, e.g. `log_max_backups = "fifteen"` or a decimal value; editing the config by hand; reading the value from an env var that contains non-numeric text.
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 size %q: missing numeric part
- 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/4382fff10896bdee.
Report an issue: GitHub.