{"record":{"id":"bc08abb3a00cd708","repo":"jackc/pgx","slug":"s-is-not-a-number","errorCode":null,"errorMessage":"%s is not a number","messagePattern":"(.+?) is not a number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/numeric.go","lineNumber":199,"sourceCode":"\treturn num, nil\n}\n\nfunc parseNumericString(str string) (n *big.Int, exp int32, err error) {\n\tidx := strings.IndexByte(str, '.')\n\n\tif idx == -1 {\n\t\tfor len(str) > 1 && str[len(str)-1] == '0' && str[len(str)-2] != '-' {\n\t\t\tstr = str[:len(str)-1]\n\t\t\texp++\n\t\t}\n\t} else {\n\t\texp = int32(-(len(str) - idx - 1))\n\t\tstr = str[:idx] + str[idx+1:]\n\t}\n\n\taccum := &big.Int{}\n\tif _, ok := accum.SetString(str, 10); !ok {\n\t\treturn nil, 0, fmt.Errorf(\"%s is not a number\", str)\n\t}\n\n\treturn accum, exp, nil\n}\n\n// nbaseDigitsToInt64 reads up to 4 nbase digits and packs them into an int64.\n// It stops early at digitsLeft or at the end of r, whichever comes first.\nfunc nbaseDigitsToInt64(r *pgio.Reader, digitsLeft int) (accum int64, digitsRead int) {\n\tdigits := min(digitsLeft, r.Remaining()/2, 4)\n\n\tfor i := range digits {\n\t\tif i > 0 {\n\t\t\taccum *= nbase\n\t\t}\n\t\taccum += int64(r.Uint16())\n\t}\n\n\treturn accum, digits","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/numeric.go#L181-L217","documentation":"parseNumericString decomposes a decimal string into a big.Int mantissa and exponent; after stripping the decimal point it calls big.Int.SetString. This guard fires when that parse reports failure — the remaining string (with '.' removed and trailing zeros possibly trimmed) is not a valid signed integer literal, so the input was never a well-formed number.","triggerScenarios":"Thrown at pgtype/numeric.go:199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate that the source string is a plain decimal number before parsing","Reject or sanitize inputs like '1.2.3', 'abc', or empty strings upstream","For JSON input, ensure the field is a JSON number, not a string with stray characters"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}