jackc/pgx · error
invalid value length %d at offset %d
Error message
invalid value length %d at offset %d
What it means
Error "invalid value length %d at offset %d" thrown in jackc/pgx.
Source
Thrown at internal/pgio/read.go:189
}
return count
}
// Value reads an int32 length followed by that many bytes — the standard
// PostgreSQL binary representation of a value. A length of -1 means NULL and
// returns (nil, true). Any other negative length is an error. The returned
// slice aliases the source; null is only meaningful if Err returns nil.
func (r *Reader) Value() (data []byte, null bool) {
offset := r.rp
length := r.Int32()
if r.err != nil {
return nil, false
}
if length == -1 {
return nil, true
}
if length < 0 {
r.fail(fmt.Errorf("invalid value length %d at offset %d", length, offset))
return nil, false
}
return r.Bytes(int(length)), false
}
// Finish returns the first error encountered, or an error if unread bytes
// remain. Decoders that must consume the entire source should end with Finish.
func (r *Reader) Finish() error {
if r.err != nil {
return r.err
}
if r.rp != len(r.s) {
return r.errTrailing()
}
return nil
}
func (r *Reader) errTrailing() error {View on GitHub (pinned to ec1a0befd2)
When it happens
Trigger: Thrown at internal/pgio/read.go:189 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: /data/errors/9f413fd29f626c36.json.
Report an issue: GitHub.