{"record":{"id":"f4bd23500cafb49e","repo":"chenhg5/cc-connect","slug":"log-backups-q-must-be-1-got-d","errorCode":null,"errorMessage":"log backups %q: must be >= 1 (got %d)","messagePattern":"log backups %q: must be >= 1 \\(got (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/logbackups.go","lineNumber":33,"sourceCode":"// minimum is 1 (one backup, the legacy behaviour); zero would mean\n// \"discard the previous log on every rotation\", which loses the entire\n// post-mortem trail at the moment something goes wrong.\n//\n// A typical rotation policy with N=3 and maxSize=10MB keeps cc-connect.log\n// plus cc-connect.log.1 / .2 / .3 on disk, so the maximum retained footprint\n// is ≈ 4 × maxSize.\nfunc ParseLogBackups(s string) (int, error) {\n\torig := s\n\ts = strings.TrimSpace(s)\n\tif s == \"\" {\n\t\treturn 0, fmt.Errorf(\"log backups: empty value\")\n\t}\n\tn, err := strconv.Atoi(s)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"log backups %q: %w\", orig, err)\n\t}\n\tif n < 1 {\n\t\treturn 0, fmt.Errorf(\"log backups %q: must be >= 1 (got %d)\", orig, n)\n\t}\n\treturn n, nil\n}\n","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/logbackups.go#L15-L37","documentation":"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.","triggerScenarios":"Calling ParseLogBackups with \"0\", \"-1\", or any integer < 1; resolveLogMaxBackups encountering such a value in the daemon config.","commonSituations":"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.","solutions":["Change log_max_backups to an integer >= 1 (e.g. 5).","If you want unlimited/no-rotation behavior, remove the log_max_backups key entirely so the default applies, rather than setting 0.","Add pre-validation at config load time to clamp or reject 0/negative values with a clearer message."],"exampleFix":"// before\nlog_max_backups = 0\n// after\nlog_max_backups = 5","handlingStrategy":"validation","validationCode":"if v, err := strconv.Atoi(cfg.LogMaxBackups); err == nil && v < 1 {\n    return fmt.Errorf(\"log_max_backups must be >= 1, got %d\", v)\n}","typeGuard":null,"tryCatchPattern":"n, err := daemon.ParseLogBackups(s)\nif err != nil {\n    if strings.Contains(err.Error(), \"must be >= 1\") {\n        // fall back to a sane default\n        n = 5\n    }\n    return err\n}","preventionTips":["Never set log_max_backups to 0 expecting 'unlimited'; remove the key instead.","Document that 0 is invalid in example configs.","Clamp values < 1 to the default before calling the parser."],"tags":["config","validation","range-check"],"backgroundTag":"value-out-of-range","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}