jackc/pgx · error
invalid array, expected ':' got
Error message
invalid array, expected ':' got %v
What it means
parseUntypedTextArray read a dimension's lower bound but the next rune was not ':'. PostgreSQL text arrays with explicit dimensions require '[lower:upper]' pairs, so a missing colon or a non-numeric lower bound that stopped early triggers this.
Solutions
- Correct the dimension syntax to '[lower:upper]' (colon required) for every dimension in the prefix
- Remove the explicit-dimension prefix and rely on the implicit '{...}' form
- Sanitize generated SQL/text that builds array literals
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/array.go:143 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/a73c37a116319185.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/array.go:143
if r == '=' {
break
} else if r != '[' {
return nil, fmt.Errorf("invalid array, expected '[' or '=' got %v", r)
}
lower, err := arrayParseInteger(buf)
if err != nil {
return nil, fmt.Errorf("invalid array: %w", err)
}
r, _, err = buf.ReadRune()
if err != nil {
return nil, fmt.Errorf("invalid array: %w", err)
}
if r != ':' {
return nil, fmt.Errorf("invalid array, expected ':' got %v", r)
}
upper, err := arrayParseInteger(buf)
if err != nil {
return nil, fmt.Errorf("invalid array: %w", err)
}
r, _, err = buf.ReadRune()
if err != nil {
return nil, fmt.Errorf("invalid array: %w", err)
}
if r != ']' {
return nil, fmt.Errorf("invalid array, expected ']' got %v", r)
}
explicitDimensions = append(explicitDimensions, ArrayDimension{LowerBound: lower, Length: upper - lower + 1})
}View on GitHub (pinned to ec1a0befd2)