jackc/pgx · error
is greater than maximum value for uint8
Error message
%d is greater than maximum value for uint8
What it means
Range guard converting an int64 into Go uint8: the value exceeds math.MaxUint8 and would overflow, so the conversion is refused.
Solutions
- Scan into a wider unsigned/signed type (uint16, uint32, int64)
- Constrain the column or query results to the 0-255 range
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/builtin_wrappers.go:142 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/8479bb007376649d.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/builtin_wrappers.go:142
func (w intWrapper) Int64Value() (Int8, error) {
return Int8{Int64: int64(w), Valid: true}, nil
}
type uint8Wrapper uint8
func (w uint8Wrapper) SkipUnderlyingTypePlan() {}
func (w *uint8Wrapper) ScanInt64(v Int8) error {
if !v.Valid {
return fmt.Errorf("cannot scan NULL into *uint8")
}
if v.Int64 < 0 {
return fmt.Errorf("%d is less than minimum value for uint8", v.Int64)
}
if v.Int64 > math.MaxUint8 {
return fmt.Errorf("%d is greater than maximum value for uint8", v.Int64)
}
*w = uint8Wrapper(v.Int64)
return nil
}
func (w uint8Wrapper) Int64Value() (Int8, error) {
return Int8{Int64: int64(w), Valid: true}, nil
}
type uint16Wrapper uint16
func (w uint16Wrapper) SkipUnderlyingTypePlan() {}
func (w *uint16Wrapper) ScanInt64(v Int8) error {
if !v.Valid {
return fmt.Errorf("cannot scan NULL into *uint16")
}View on GitHub (pinned to ec1a0befd2)