{"record":{"id":"3bba3046ea5a92e6","repo":"vitessio/vitess","slug":"invalid-base-d-must-be-in-2-36","errorCode":null,"errorMessage":"invalid base %d; must be in [2, 36]","messagePattern":"invalid base (.+?); must be in \\[2, 36\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/fastparse/fastparse.go","lineNumber":44,"sourceCode":"\nfunc ParseUint64(s string, base int) (uint64, error) {\n\treturn parseUint64(s, base, false)\n}\n\nfunc ParseUint64WithNeg(s string, base int) (uint64, error) {\n\treturn parseUint64(s, base, true)\n}\n\n// ParseUint64 parses uint64 from s.\n//\n// It is equivalent to strconv.ParseUint(s, base, 64) in case it succeeds,\n// but on error it will return the best effort value of what it has parsed so far.\nfunc parseUint64(s string, base int, allowNeg bool) (uint64, error) {\n\tif len(s) == 0 {\n\t\treturn 0, errors.New(\"cannot parse uint64 from empty string\")\n\t}\n\tif base < 2 || base > 36 {\n\t\treturn 0, fmt.Errorf(\"invalid base %d; must be in [2, 36]\", base)\n\t}\n\ti := uint(0)\n\tfor i < uint(len(s)) {\n\t\tif !isSpace(s[i]) {\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t}\n\n\tif i >= uint(len(s)) {\n\t\treturn 0, fmt.Errorf(\"cannot parse uint64 from %q\", s)\n\t}\n\t// For some reason, MySQL parses things as uint64 even with\n\t// a negative sign and then turns it into the 2s complement value.\n\tminus := s[i] == '-'\n\tif minus {\n\t\tif !allowNeg {\n\t\t\treturn 0, fmt.Errorf(\"cannot parse uint64 from %q\", s)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/fastparse/fastparse.go#L26-L62","documentation":"The fastparse package's parseUint64 supports bases 2 through 36 (matching strconv). If ParseUint64 or ParseUint64WithNeg is invoked with a base outside this range, it fails fast with this error before consuming any input. Unlike strconv, this package returns a best-effort value plus error on parse failures, but an invalid base is rejected outright with 0.","triggerScenarios":"Calling fastparse.ParseUint64/ParseUint64WithNeg with base < 2 (e.g. 0, 1, or the strconv special-case base 0 for auto-detection, which is NOT supported here) or base > 36.","commonSituations":"Porting code from strconv.ParseUint(s, 0, 64) and keeping base 0; computing the base dynamically from config or user input that yields 0 or an invalid number; typo like base 1 for \"unary\" parsing.","solutions":["Pass an explicit base between 2 and 36; use base 10 for decimal parsing.","If you relied on strconv's base-0 auto-detection (0x/0b/0o prefixes), detect and strip the prefix yourself before calling with base 16/2/8.","Clamp or validate any dynamic base value before passing it: if base < 2 || base > 36, handle it at the call site."],"exampleFix":"// before\nv, _ := fastparse.ParseUint64(s, 0) // base 0 not supported\n\n// after\nv, _ := fastparse.ParseUint64(s, 10)","handlingStrategy":"validation","validationCode":"func validBase(base int) bool { return base >= 2 && base <= 36 }\n// before calling:\n// if !validBase(base) { return error }","typeGuard":null,"tryCatchPattern":"v, err := fastparse.ParseUint64(s, base)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid base\") {\n        v, err = fastparse.ParseUint64(s, 10) // fall back to decimal\n    }\n}","preventionTips":["Pass literal, explicit bases (usually 10) instead of computed values.","Do not reuse strconv's base-0 convention — fastparse does not auto-detect prefixes.","Clamp dynamic base values to [2, 36] at configuration time.","Add a table-driven test over the bases your code uses."],"tags":["parsing","fastparse","integer","invalid-argument"],"backgroundTag":"invalid-number-base","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}