jackc/pgx · error
invalid array value
Error message
invalid array value: %w
What it means
A wrapper guard around arrayParseValue while scanning element text inside the '{...}' body: the element parser returned an error (e.g. unterminated quoted value), and it is re-wrapped as 'invalid array value'. The fault is in the element text, not the surrounding structure.
Solutions
- Inspect the wrapped error to find the offending element text
- Fix quoting/escaping of element values (double quotes and backslashes must be escaped in quoted elements)
- Re-encode the value via PostgreSQL or a pgx array encoder rather than hand-building the literal
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/array.go:215 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/16f4630d156fa7c9.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/array.go:215
}
switch r {
case '{':
if currentDim == counterDim {
implicitDimensions[currentDim].Length++
}
currentDim++
case ',':
case '}':
currentDim--
if currentDim < counterDim {
counterDim = currentDim
}
default:
buf.UnreadRune()
value, quoted, err := arrayParseValue(buf)
if err != nil {
return nil, fmt.Errorf("invalid array value: %w", err)
}
if currentDim == counterDim {
implicitDimensions[currentDim].Length++
}
dst.Quoted = append(dst.Quoted, quoted)
dst.Elements = append(dst.Elements, value)
}
if currentDim < 0 {
break
}
}
skipWhitespace(buf)
if buf.Len() > 0 {
return nil, fmt.Errorf("unexpected trailing data: %v", buf.String())
}View on GitHub (pinned to ec1a0befd2)