{"record":{"id":"4382fff10896bdee","repo":"chenhg5/cc-connect","slug":"log-backups-q-w","errorCode":null,"errorMessage":"log backups %q: %w","messagePattern":"log backups %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/logbackups.go","lineNumber":30,"sourceCode":"// 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":12,"sourceCodeEnd":37,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/logbackups.go#L12-L37","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlog_max_backups = \"10x\"\n// after\nlog_max_backups = \"10\"","handlingStrategy":"validation","validationCode":"if v := strings.TrimSpace(cfg.LogMaxBackups); v != \"\" {\n    if _, err := strconv.Atoi(v); err != nil {\n        return fmt.Errorf(\"log_max_backups must be an integer, got %q\", cfg.LogMaxBackups)\n    }\n}","typeGuard":null,"tryCatchPattern":"n, err := daemon.ParseLogBackups(s)\nif err != nil {\n    var numErr *strconv.NumError\n    if errors.As(err, &numErr) {\n        // handle non-numeric input specifically\n    }\n    return err\n}","preventionTips":["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."],"tags":["config","parsing","validation"],"backgroundTag":"invalid-config-value","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"}