{"record":{"id":"6d0bfb6d845cf8da","repo":"chenhg5/cc-connect","slug":"log-size-q-w","errorCode":null,"errorMessage":"log size %q: %w","messagePattern":"log size %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/logsize.go","lineNumber":76,"sourceCode":"\t\tmultiplier = 1024\n\t\tnumPart = s[:len(s)-len(\"K\")]\n\tcase strings.HasSuffix(upper, \"B\"):\n\t\t// Explicit bytes — only the bare \"B\" suffix (not \"XB\" for some X).\n\t\t// The \"KB\"/\"MB\"/\"GB\"/\"TB\" cases above are tried first and win.\n\t\tmultiplier = 1\n\t\tnumPart = s[:len(s)-len(\"B\")]\n\tdefault:\n\t\tnumPart = s\n\t}\n\n\tnumPart = strings.TrimSpace(numPart)\n\tif numPart == \"\" {\n\t\treturn 0, fmt.Errorf(\"log size %q: missing numeric part\", orig)\n\t}\n\n\tn, err := strconv.ParseInt(numPart, 10, 64)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"log size %q: %w\", orig, err)\n\t}\n\tif n < 0 {\n\t\treturn 0, fmt.Errorf(\"log size %q: must be non-negative\", orig)\n\t}\n\n\treturn n * multiplier, nil\n}\n","sourceCodeStart":58,"sourceCodeEnd":84,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/logsize.go#L58-L84","documentation":"ParseLogSize parses the numeric portion with strconv.ParseInt and wraps any parse failure with the original input. This error is returned when the numeric part is present but not a valid 64-bit integer (e.g. contains a decimal point, hex digits, or stray characters).","triggerScenarios":"Calling ParseLogSize with values like \"1.5GB\", \"0x10M\", \"10 MB\" (inner space left in numeric part), or \"10,000MB\".","commonSituations":"Decimal sizes like \"1.5GB\" which the parser does not support; thousands separators; Unicode spaces or NBSP pasted from docs; leading + sign.","solutions":["Use an integer value: write \"1536MB\" instead of \"1.5GB\".","Remove separators/spaces inside the number: \"10000MB\" not \"10,000 MB\".","Inspect the wrapped strconv error to identify the offending character."],"exampleFix":"// before\nlog_max_size = \"1.5GB\"\n// after\nlog_max_size = \"1536MB\"","handlingStrategy":"validation","validationCode":"num := regexp.MustCompile(`^\\d+$`)\nif !num.MatchString(strings.TrimRight(strings.TrimSpace(cfg.LogMaxSize), \"KMGTB\")) {\n    return fmt.Errorf(\"log_max_size numeric part must be a plain integer\")\n}","typeGuard":null,"tryCatchPattern":"size, err := daemon.ParseLogSize(s)\nif err != nil {\n    var numErr *strconv.NumError\n    if errors.As(err, &numErr) {\n        return fmt.Errorf(\"%q is not a valid integer size; decimals like 1.5GB are unsupported\", s)\n    }\n    return err\n}","preventionTips":["Avoid decimal sizes (1.5GB); express them as integers (1536MB).","Strip thousands separators before passing the value.","Beware pasted NBSP/Unicode spaces; normalize whitespace first."],"tags":["config","parsing","int64"],"backgroundTag":"invalid-argument-format","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"}