jackc/pgx · error
invalid length for point
Error message
invalid length for point: %v
What it means
parsePoint parses the textual '(x,y)' point representation (optionally JSON-quoted). This length guard fires when the source is shorter than the 5-byte minimum — even the shortest possible point like '(1,2)' — so the string cannot possibly contain a coordinate pair. It is reached from Point's JSON unmarshaling and text scanning.
Solutions
- Ensure point values are in '(x,y)' text form (or JSON "(x,y)")
- Validate JSON input length before parsing
- Fix custom code producing truncated point strings
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/point.go:49 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/2939e55f52d6f823.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/point.go:49
// ScanPoint implements the [PointScanner] interface.
func (p *Point) ScanPoint(v Point) error {
*p = v
return nil
}
// PointValue implements the [PointValuer] interface.
func (p Point) PointValue() (Point, error) {
return p, nil
}
func parsePoint(src []byte) (*Point, error) {
if src == nil || bytes.Equal(src, []byte("null")) {
return &Point{}, nil
}
if len(src) < 5 {
return nil, fmt.Errorf("invalid length for point: %v", len(src))
}
if src[0] == '"' && src[len(src)-1] == '"' {
src = src[1 : len(src)-1]
}
sx, sy, found := strings.Cut(string(src[1:len(src)-1]), ",")
if !found {
return nil, fmt.Errorf("invalid format for point")
}
x, err := strconv.ParseFloat(sx, 64)
if err != nil {
return nil, err
}
y, err := strconv.ParseFloat(sy, 64)
if err != nil {
return nil, err
}View on GitHub (pinned to ec1a0befd2)