{"record":{"id":"c1b97c00777aa1a6","repo":"vitessio/vitess","slug":"unparsed-tail-left-after-parsing-float64-from-q","errorCode":null,"errorMessage":"unparsed tail left after parsing float64 from %q: %q","messagePattern":"unparsed tail left after parsing float64 from %q: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/mysql/fastparse/fastparse.go","lineNumber":270,"sourceCode":"\t\tif !isSpace(s[i]) {\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t}\n\tws := i\n\n\t// We only care to parse as many of the initial float characters of the\n\t// string as possible.\n\tval, l, err := Atof64(s[ws:])\n\tfor l < len(s[ws:]) {\n\t\tif !isSpace(s[ws+uint(l)]) {\n\t\t\tbreak\n\t\t}\n\t\tl++\n\t}\n\n\tif l < len(s[ws:]) {\n\t\treturn val, fmt.Errorf(\"unparsed tail left after parsing float64 from %q: %q\", s, s[ws+uint(l):])\n\t}\n\tif errors.Is(err, strconv.ErrRange) {\n\t\tif val < 0 {\n\t\t\tval = -math.MaxFloat64\n\t\t} else {\n\t\t\tval = math.MaxFloat64\n\t\t}\n\t}\n\n\treturn val, err\n}\n\nfunc isSpace(c byte) bool {\n\tswitch c {\n\tcase ' ', '\\t':\n\t\treturn true\n\tdefault:\n\t\treturn false","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/fastparse/fastparse.go#L252-L288","documentation":"ParseFloat64 parses as many leading float characters as possible from the input; if after skipping trailing spaces/tabs there are still unconsumed characters, it returns the parsed value plus this error naming the leftover tail. Like ParseInt64, it implements MySQL's lenient prefix-parsing behavior while flagging the leftover content.","triggerScenarios":"ParseFloat64(\"1.5abc\"), ParseFloat64(\"1,234.5\"), ParseFloat64(\"12e\") or any string where Atof64 stops before the end and the remainder is not whitespace.","commonSituations":"Floating-point SQL literals with units or separators (\"3.14rad\"), locale-formatted numbers with comma thousands separators, or double-parsed values where a numeric string was embedded in longer text.","solutions":["Reject the value when this error occurs unless truncation semantics are explicitly wanted.","Normalize the input first: strip units, replace comma separators, trim whitespace.","Use strconv.ParseFloat directly if strict full-string parsing is required."],"exampleFix":"// before\nval, err := fastparse.ParseFloat64(s)\n// after\nval, err := fastparse.ParseFloat64(s)\nif err != nil && strings.Contains(err.Error(), \"unparsed tail\") {\n    return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, \"invalid float literal %q\", s)\n}","handlingStrategy":"validation","validationCode":"func strictFloat64(s string) (float64, error) {\n    s = strings.TrimSpace(s)\n    if _, err := strconv.ParseFloat(s, 64); err != nil {\n        return 0, vterrors.Wrapf(err, vtrpcpb.Code_INVALID_ARGUMENT, \"not a plain float: %q\", s)\n    }\n    return fastparse.ParseFloat64(s)\n}","typeGuard":null,"tryCatchPattern":"val, err := fastparse.ParseFloat64(s)\nif err != nil {\n    return 0, vterrors.Wrapf(err, vtrpcpb.Code_INVALID_ARGUMENT, \"invalid float literal %q\", s)\n}","preventionTips":["Use strconv.ParseFloat for strict full-string validation before lenient parsing.","Normalize locale separators and strip units from numeric strings.","Do not use the returned value when an 'unparsed tail' error occurred unless truncation is intended."],"tags":["parsing","float64","trailing-characters"],"backgroundTag":"number-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}