{"record":{"id":"881ca3dbad7f6173","repo":"chenhg5/cc-connect","slug":"log-size-q-missing-numeric-part","errorCode":null,"errorMessage":"log size %q: missing numeric part","messagePattern":"log size %q: missing numeric part","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/logsize.go","lineNumber":71,"sourceCode":"\t\tnumPart = s[:len(s)-len(\"M\")]\n\tcase strings.HasSuffix(upper, \"KB\"):\n\t\tmultiplier = 1024\n\t\tnumPart = s[:len(s)-len(\"KB\")]\n\tcase strings.HasSuffix(upper, \"K\"):\n\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":53,"sourceCodeEnd":84,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/logsize.go#L53-L84","documentation":"ParseLogSize splits the input into a numeric part and an optional size suffix (K/KB/M/MB/G/GB/T/TB). This error is returned when after stripping a recognized suffix there is no numeric text left, e.g. the value is just a suffix like \"MB\".","triggerScenarios":"Calling ParseLogSize with inputs like \"MB\", \"KB\", \"GB\", or a suffix with surrounding spaces where the numeric part is empty after trimming.","commonSituations":"User writes log_max_size = \"GB\" instead of \"10GB\"; copy/paste dropping the number; config value edited so the digits were accidentally deleted.","solutions":["Include the number with the unit, e.g. \"10GB\" instead of \"GB\".","Use a bare integer if no suffix is desired (bytes), e.g. \"10737418240\".","Check the echoed original value %q in the message to spot the malformed input."],"exampleFix":"// before\nlog_max_size = \"GB\"\n// after\nlog_max_size = \"10GB\"","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`^\\d+\\s*(K|KB|M|MB|G|GB|T|TB)?$`)\nif !re.MatchString(strings.TrimSpace(cfg.LogMaxSize)) {\n    return fmt.Errorf(\"log_max_size %q must be a number with optional unit, e.g. \\\"100MB\\\"\", cfg.LogMaxSize)\n}","typeGuard":null,"tryCatchPattern":"size, err := daemon.ParseLogSize(s)\nif err != nil {\n    if strings.Contains(err.Error(), \"missing numeric part\") {\n        return fmt.Errorf(\"add a number before the unit, e.g. \\\"10GB\\\"\")\n    }\n    return err\n}","preventionTips":["Always pair the unit with a number: \"10GB\", never \"GB\".","Copy size values from documented examples rather than typing units alone.","Pre-validate with a regex matching number + optional unit."],"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"}