jackc/pgx · error
is greater than maximum value for Uint32
Error message
%d is greater than maximum value for Uint32
What it means
Uint32.Scan range guard: the incoming value exceeds math.MaxUint32 and would overflow a uint32, so the scan is rejected.
Solutions
- Scan into pgtype.Uint64 or a wider type
- Constrain the source values to the uint32 range
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/uint32.go:64 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/89310ed87da93bdd.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/uint32.go:64
switch src := src.(type) {
case int64:
n = src
case string:
un, err := strconv.ParseUint(src, 10, 32)
if err != nil {
return err
}
n = int64(un)
default:
return fmt.Errorf("cannot scan %T", src)
}
if n < 0 {
return fmt.Errorf("%d is less than the minimum value for Uint32", n)
}
if n > math.MaxUint32 {
return fmt.Errorf("%d is greater than maximum value for Uint32", n)
}
*dst = Uint32{Uint32: uint32(n), Valid: true}
return nil
}
// Value implements the [database/sql/driver.Valuer] interface.
func (src Uint32) Value() (driver.Value, error) {
if !src.Valid {
return nil, nil
}
return int64(src.Uint32), nil
}
// MarshalJSON implements the [encoding/json.Marshaler] interface.
func (src Uint32) MarshalJSON() ([]byte, error) {
if !src.Valid {View on GitHub (pinned to ec1a0befd2)