jackc/pgx · error
invalid upper value
Error message
invalid upper value: %w
What it means
The parser could not read the first rune of the upper bound (end of input after the separator). The wrapped error is the buffer read error; the literal ended immediately after ',' with no upper value or closing bracket.
Solutions
- Ensure the range literal includes an upper bound or is unbounded with ')' / ']'
- Validate completeness of the input string before parsing
- Detect and reject truncated range strings at the application boundary
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/range.go:80 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/acc37417be8315e6.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/range.go:80
utr.LowerType = Unbounded
} else {
utr.Lower, err = rangeParseValue(buf)
if err != nil {
return nil, fmt.Errorf("invalid lower value: %w", err)
}
}
r, _, err = buf.ReadRune()
if err != nil {
return nil, fmt.Errorf("missing range separator: %w", err)
}
if r != ',' {
return nil, fmt.Errorf("missing range separator: %v", r)
}
r, _, err = buf.ReadRune()
if err != nil {
return nil, fmt.Errorf("invalid upper value: %w", err)
}
if r == ')' || r == ']' {
utr.UpperType = Unbounded
} else {
buf.UnreadRune()
utr.Upper, err = rangeParseValue(buf)
if err != nil {
return nil, fmt.Errorf("invalid upper value: %w", err)
}
r, _, err = buf.ReadRune()
if err != nil {
return nil, fmt.Errorf("missing upper bound: %w", err)
}
switch r {
case ')':
utr.UpperType = ExclusiveView on GitHub (pinned to ec1a0befd2)