jackc/pgx · error
numeric incomplete
Error message
numeric incomplete %v
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/numeric.go:654 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /api/errors/67807db89686a739.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/numeric.go:654
if err := r.Err(); err != nil {
return fmt.Errorf("numeric incomplete: %w", err)
}
switch sign {
case pgNumericNaNSign:
return scanner.ScanNumeric(Numeric{NaN: true, Valid: true})
case pgNumericPosInfSign:
return scanner.ScanNumeric(Numeric{InfinityModifier: Infinity, Valid: true})
case pgNumericNegInfSign:
return scanner.ScanNumeric(Numeric{InfinityModifier: NegativeInfinity, Valid: true})
}
if ndigits == 0 {
return scanner.ScanNumeric(Numeric{Int: big.NewInt(0), Valid: true})
}
if r.Remaining() < int(ndigits)*2 {
return fmt.Errorf("numeric incomplete %v", src)
}
accum := &big.Int{}
// int(ndigits) before the addition: ndigits is a uint16, so ndigits+3
// would wrap for counts above 65532 and skip the loop entirely.
for i := 0; i < (int(ndigits)+3)/4; i++ {
int64accum, digitsRead := nbaseDigitsToInt64(r, int(ndigits)-i*4)
if i > 0 {
var mul *big.Int
switch digitsRead {
case 1:
mul = bigNBase
case 2:
mul = bigNBaseX2
case 3:
mul = bigNBaseX3View on GitHub (pinned to ec1a0befd2)