{"record":{"id":"8680dfb71005b50e","repo":"chenhg5/cc-connect","slug":"log-backups-empty-value","errorCode":null,"errorMessage":"log backups: empty value","messagePattern":"log backups: empty value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/logbackups.go","lineNumber":26,"sourceCode":"\n// ParseLogBackups converts a string into a positive integer count of log\n// backups to retain when the rotating writer rotates the active log file.\n// Unlike ParseLogSize, no unit suffix is accepted — a backup count is\n// already an integer in any sane unit. Whitespace is trimmed.\n//\n// Returns an error if the input is empty, non-integer, or not >= 1. The\n// 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":8,"sourceCodeEnd":37,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/logbackups.go#L8-L37","documentation":"ParseLogBackups input guard: the log_backups value is empty after trimming, so no backup count can be derived. The minimum accepted is 1 because zero backups would discard the previous log on every rotation, destroying the post-mortem trail.","triggerScenarios":"Thrown at daemon/logbackups.go:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set log_backups to an integer >= 1 (no unit suffix accepted)","Remove the key to use the default backup count"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}