jackc/pgx · error
invalid format for line
Error message
invalid format for line
What it means
After stripping the outer braces from a line text value, the parser splits on commas and requires exactly three components (A, B, C). This guard fires when the split yields fewer than three parts — the inner content is not a comma-separated triple as the format requires.
Solutions
- Store the value in canonical '{a,b,c}' format
- Sanitize or reformat the source string before it reaches the database
- Use binary format encoding for the line column
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/line.go:188 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/b8707dafb76d1c91.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/line.go:188
})
}
type scanPlanTextAnyToLineScanner struct{}
func (scanPlanTextAnyToLineScanner) Scan(src []byte, dst any) error {
scanner := (dst).(LineScanner)
if src == nil {
return scanner.ScanLine(Line{})
}
if len(src) < 7 {
return fmt.Errorf("invalid length for line: %v", len(src))
}
parts := strings.SplitN(string(src[1:len(src)-1]), ",", 3)
if len(parts) < 3 {
return fmt.Errorf("invalid format for line")
}
a, err := strconv.ParseFloat(parts[0], 64)
if err != nil {
return err
}
b, err := strconv.ParseFloat(parts[1], 64)
if err != nil {
return err
}
c, err := strconv.ParseFloat(parts[2], 64)
if err != nil {
return err
}
return scanner.ScanLine(Line{A: a, B: b, C: c, Valid: true})View on GitHub (pinned to ec1a0befd2)