jackc/pgx · error
array header
Error message
array header: %w
What it means
While decoding a binary array, reading the fixed-size header portion failed — the buffer ran short or the reader errored. The wrapped error is from the pgio reader, typically unexpected EOF on truncated array data.
Solutions
- Verify the binary array data is complete and not truncated
- Check that the column actually contains an array type
- Inspect the wrapped error for the reader's specific failure
- Test with a simple array value to isolate the issue
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/array.go:51 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/8e5206a887313082.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/array.go:51
}
elementCount := int(dimensions[0].Length)
for _, d := range dimensions[1:] {
elementCount *= int(d.Length)
}
if elementCount < 0 {
return 0
}
return elementCount
}
func (dst *arrayHeader) DecodeBinary(r *pgio.Reader) error {
// Each dimension is 8 bytes, which also bounds the Dimensions allocation below.
numDims := r.Count(8)
if err := r.Err(); err != nil {
return fmt.Errorf("array header: %w", err)
}
if numDims > 6 {
return fmt.Errorf("array has too many dimensions: %d", numDims)
}
dst.ContainsNull = r.Uint32() == 1
dst.ElementOID = r.Uint32()
dst.Dimensions = make([]ArrayDimension, numDims)
for i := range dst.Dimensions {
dst.Dimensions[i].Length = r.Int32()
dst.Dimensions[i].LowerBound = r.Int32()
}
if err := r.Err(); err != nil {
return fmt.Errorf("array header: %w", err)
}View on GitHub (pinned to ec1a0befd2)