jackc/pgx · error
is less than minimum value for uint
Error message
%d is less than minimum value for uint
What it means
scanPlanBinaryInt2ToUint decoded a negative int2 value; an unsigned uint target cannot hold it, so the scan is rejected.
Solutions
- Scan into a signed Go type (int/int16)
- Constrain the column to non-negative values
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/int.go:546 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/bdc4adbab2e5a53f.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/int.go:546
func (scanPlanBinaryInt2ToUint) Scan(src []byte, dst any) error {
if src == nil {
return fmt.Errorf("cannot scan NULL into %T", dst)
}
raw, err := pgio.Uint16Exact(src)
if err != nil {
return fmt.Errorf("uint2: %w", err)
}
p, ok := (dst).(*uint)
if !ok {
return ErrScanTargetTypeChanged
}
n := int64(int16(raw))
if n < 0 {
return fmt.Errorf("%d is less than minimum value for uint", n)
}
*p = uint(n)
return nil
}
type scanPlanBinaryInt2ToInt64Scanner struct{}
func (scanPlanBinaryInt2ToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner)
if !ok {
return ErrScanTargetTypeChanged
}
if src == nil {
return s.ScanInt64(Int8{})
}View on GitHub (pinned to ec1a0befd2)