chenhg5/cc-connect · error

log backups %q: must be >= 1 (got %d)

Error message

log backups %q: must be >= 1 (got %d)

What it means

ParseLogBackups requires the parsed backup count to be at least 1. This error is thrown when the value parses as an integer but is 0 or negative, which would mean no backups or nonsensical rotation retention.

Source

Thrown at daemon/logbackups.go:33

// 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

  1. Change log_max_backups to an integer >= 1 (e.g. 5).
  2. If you want unlimited/no-rotation behavior, remove the log_max_backups key entirely so the default applies, rather than setting 0.
  3. Add pre-validation at config load time to clamp or reject 0/negative values with a clearer message.

Example fix

// before
log_max_backups = 0
// after
log_max_backups = 5
Defensive patterns

Strategy: validation

Validate before calling

if v, err := strconv.Atoi(cfg.LogMaxBackups); err == nil && v < 1 {
    return fmt.Errorf("log_max_backups must be >= 1, got %d", v)
}

Try / catch

n, err := daemon.ParseLogBackups(s)
if err != nil {
    if strings.Contains(err.Error(), "must be >= 1") {
        // fall back to a sane default
        n = 5
    }
    return err
}

Prevention

When it happens

Trigger: Calling ParseLogBackups with "0", "-1", or any integer < 1; resolveLogMaxBackups encountering such a value in the daemon config.

Common situations: User sets log_max_backups = 0 thinking it means 'unlimited' or 'disable rotation'; a negative number typed accidentally; a script generating the config defaults to 0.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/f4bd23500cafb49e. Report an issue: GitHub.