jackc/pgx · error

invalid format for point

Error message

invalid format for point

What it means

After stripping the surrounding parentheses (and optional quotes) from a point string, parsePoint splits the interior on the first comma. This guard fires when no comma is found — the content between the parens is not a comma-separated x,y pair, so the text is not a valid point literal.

Solutions

  1. Store points in canonical '(x,y)' text format
  2. Validate JSON string values for points before unmarshaling
  3. Use binary format encoding for point columns
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/point.go:56 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/3532a2ffc8956396. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/point.go:56

// 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
	}

	return &Point{P: Vec2{x, y}, Valid: true}, nil
}

// Scan implements the [database/sql.Scanner] interface.
func (dst *Point) Scan(src any) error {
	if src == nil {

View on GitHub (pinned to ec1a0befd2)