jackc/pgx · error
missing upper bound
Error message
missing upper bound: %w
What it means
parseUntypedTextRange read the upper bound value but then hit EOF (ReadRune error) before finding the closing ')' or ']'. The range literal's upper bound is missing its terminator, so the wrapped read error is reported.
Solutions
- Ensure the range literal ends with ')' or ']'
- Pre-validate the bracket balance of range strings
- Round-trip the value through the database to normalize formatting
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/range.go:94 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/ca373b15a9d89cf6.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/range.go:94
}
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 = Exclusive
case ']':
utr.UpperType = Inclusive
default:
return nil, fmt.Errorf("missing upper bound, instead got: %v", string(r))
}
}
skipWhitespace(buf)
if buf.Len() > 0 {
return nil, fmt.Errorf("unexpected trailing data: %v", buf.String())
}
return utr, nilView on GitHub (pinned to ec1a0befd2)