jackc/pgx · error
invalid length for Path with
Error message
invalid length for Path with %d points: %w
What it means
After reading the declared number of 16-byte points from a binary path, the plan requires the buffer to be exactly exhausted. This wrapper fires when pgio's Finish reports leftover bytes — the payload length does not equal 1 + pointCount*16, meaning the value is padded or malformed relative to its own point count.
Solutions
- Verify the binary path's byte length matches its point count
- Use text format for the column
- Report as a driver bug if the value came from the server
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/path.go:197 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/2ba30c7608eb01ec.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/path.go:197
r := pgio.NewReader(src)
closed := r.Byte() == 1
// Each point is two float64s.
pointCount := r.Count(16)
if err := r.Err(); err != nil {
return fmt.Errorf("invalid length for Path: %w", err)
}
points := make([]Vec2, pointCount)
for i := range points {
x := r.Uint64()
y := r.Uint64()
points[i] = Vec2{math.Float64frombits(x), math.Float64frombits(y)}
}
if err := r.Finish(); err != nil {
return fmt.Errorf("invalid length for Path with %d points: %w", pointCount, err)
}
return scanner.ScanPath(Path{
P: points,
Closed: closed,
Valid: true,
})
}
type scanPlanTextAnyToPathScanner struct{}
func (scanPlanTextAnyToPathScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PathScanner)
if src == nil {
return scanner.ScanPath(Path{})
}
View on GitHub (pinned to ec1a0befd2)