{"record":{"id":"67807db89686a739","repo":"jackc/pgx","slug":"numeric-incomplete-v","errorCode":null,"errorMessage":"numeric incomplete %v","messagePattern":"numeric incomplete (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/numeric.go","lineNumber":654,"sourceCode":"\tif err := r.Err(); err != nil {\n\t\treturn fmt.Errorf(\"numeric incomplete: %w\", err)\n\t}\n\n\tswitch sign {\n\tcase pgNumericNaNSign:\n\t\treturn scanner.ScanNumeric(Numeric{NaN: true, Valid: true})\n\tcase pgNumericPosInfSign:\n\t\treturn scanner.ScanNumeric(Numeric{InfinityModifier: Infinity, Valid: true})\n\tcase pgNumericNegInfSign:\n\t\treturn scanner.ScanNumeric(Numeric{InfinityModifier: NegativeInfinity, Valid: true})\n\t}\n\n\tif ndigits == 0 {\n\t\treturn scanner.ScanNumeric(Numeric{Int: big.NewInt(0), Valid: true})\n\t}\n\n\tif r.Remaining() < int(ndigits)*2 {\n\t\treturn fmt.Errorf(\"numeric incomplete %v\", src)\n\t}\n\n\taccum := &big.Int{}\n\n\t// int(ndigits) before the addition: ndigits is a uint16, so ndigits+3\n\t// would wrap for counts above 65532 and skip the loop entirely.\n\tfor i := 0; i < (int(ndigits)+3)/4; i++ {\n\t\tint64accum, digitsRead := nbaseDigitsToInt64(r, int(ndigits)-i*4)\n\n\t\tif i > 0 {\n\t\t\tvar mul *big.Int\n\t\t\tswitch digitsRead {\n\t\t\tcase 1:\n\t\t\t\tmul = bigNBase\n\t\t\tcase 2:\n\t\t\t\tmul = bigNBaseX2\n\t\t\tcase 3:\n\t\t\t\tmul = bigNBaseX3","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/numeric.go#L636-L672","documentation":"After the binary numeric header is read, the payload must contain ndigits * 2 more bytes of digit data. This guard fires when fewer bytes remain than the declared digit count requires — the header promises more digits than the buffer actually carries, so the value is truncated or inconsistent.","triggerScenarios":"Thrown at pgtype/numeric.go:654 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the binary numeric value's length matches its declared ndigits field","Use text format for the column","Check for truncation in custom binary handling code"],"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"}