jackc/pgx · error
invalid tsvector format: expected position number
Error message
invalid tsvector format: expected position number
What it means
consumePosition expected a decimal position number after ':' or ',' in a lexeme's position list, but no digits were found at the current position (e.g. 'a:,' or 'a:x').
Solutions
- Write positions as decimal numbers, e.g. 'a:1,2 b:3'
- Remove stray ':' or ',' after lexemes without positions
- Regenerate the tsvector with to_tsvector
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/tsvector.go:428 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/766a215ac97a2f4b.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/tsvector.go:428
break
}
p.consume() // skip ','
}
return positions, nil
}
// consumePosition consumes a single position number with optional weight letter.
func (p *tsvectorParser) consumePosition() (TSVectorPosition, error) {
start := p.pos
for !p.atEnd() && p.peek() >= '0' && p.peek() <= '9' {
p.consume()
}
if p.pos == start {
return TSVectorPosition{}, fmt.Errorf("invalid tsvector format: expected position number")
}
num, err := strconv.ParseUint(p.str[start:p.pos], 10, 16)
if err != nil {
return TSVectorPosition{}, fmt.Errorf("invalid tsvector format: invalid position number %q", p.str[start:p.pos])
}
pos := TSVectorPosition{Position: uint16(num), Weight: TSVectorWeightD}
// Check for optional weight letter
if !p.atEnd() {
switch p.peek() {
case 'A', 'a':
pos.Weight = TSVectorWeightA
case 'B', 'b':
pos.Weight = TSVectorWeightB
case 'C', 'c':
pos.Weight = TSVectorWeightCView on GitHub (pinned to ec1a0befd2)