{"record":{"id":"2fa246cfe9e14a5b","repo":"probelabs/goreplay","slug":"invalid-len-q","errorCode":null,"errorMessage":"invalid _len %q","messagePattern":"invalid _len %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/size/size.go","lineNumber":56,"sourceCode":"\n\tvar _len int64\n\tswitch {\n\tcase rB.Match(s):\n\t\t_len, err = strconv.ParseInt(size, 0, 64)\n\tcase rKB.Match(s):\n\t\t_len, err = strconv.ParseInt(size[:lmt], 0, 64)\n\t\t_len *= KB\n\tcase rMB.Match(s):\n\t\t_len, err = strconv.ParseInt(size[:lmt], 0, 64)\n\t\t_len *= MB\n\tcase rGB.Match(s):\n\t\t_len, err = strconv.ParseInt(size[:lmt], 0, 64)\n\t\t_len *= GB\n\tcase rTB.Match(s):\n\t\t_len, err = strconv.ParseInt(size[:lmt], 0, 64)\n\t\t_len *= TB\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid _len %q\", size)\n\t}\n\t*siz = Size(_len)\n\treturn\n}\n\nfunc (siz *Size) String() string {\n\treturn fmt.Sprintf(\"%d\", *siz)\n}\n","sourceCodeStart":38,"sourceCodeEnd":65,"githubUrl":"https://github.com/probelabs/goreplay/blob/251e45abd242886bb64ff2b2dc98789556b56330/internal/size/size.go#L38-L65","documentation":"Size.Set parses a human-readable data-unit string (e.g. '10KB', '2MB') using unit suffix matchers; if the string ends in a suffix no matcher recognizes, it returns fmt.Errorf(\"invalid _len %q\", size). This means the input did not match any supported unit (B, KB, MB, GB, TB, etc.).","triggerScenarios":"Calling Size.Set (or a parser that delegates to it, like TestParseDataUnit exercises) with a string whose unit suffix is unknown, misspelled, or missing — e.g. '10kib', '5 GIG', '10', '10XB'.","commonSituations":"Reading sizes from config files/env vars where users write '10GiB' or '10 Mb' while the parser only accepts its specific suffix set; missing unit entirely; lowercase/uppercase mismatch if matchers are case-sensitive; test fixtures using unsupported units.","solutions":["Use a supported unit suffix exactly as accepted by the parser (e.g. B, KB, MB, GB, TB with matching case).","Check the regex set in internal/size/size.go and conform the input to it.","Pre-normalize input (trim spaces, canonicalize case) before calling Set.","Extend the matchers if a new unit (e.g. KiB) is genuinely needed, adding a case that multiplies by the right factor."],"exampleFix":"// before\nsize.Set(\"10GiB\") // invalid _len \"10GiB\"\n// after\nsize.Set(\"10GB\") // matches the GB suffix matcher","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`(?i)^\\d+\\s*(b|kb|mb|gb|tb)$`)\nif !re.MatchString(input) {\n\treturn fmt.Errorf(\"unsupported size %q; use e.g. 10KB\", input)\n}","typeGuard":null,"tryCatchPattern":"var siz size.Size\nif err := siz.Set(userValue); err != nil {\n\treturn fmt.Errorf(\"invalid size %q: %w\", userValue, err)\n}","preventionTips":["Normalize input (trim spaces, canonical case) before Set","Document accepted unit suffixes next to the config field","Add table-driven tests for supported and rejected formats","Reject empty or unitless values early"],"tags":["parsing","validation","units","go"],"backgroundTag":"invalid-size-format","analyzedSha":"251e45abd242886bb64ff2b2dc98789556b56330","analyzedAt":"2026-09-02T16:44:11.369Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}