jackc/pgx · error
number of field descriptions must equal number of values…
Error message
number of field descriptions must equal number of values, got %d and %d
What it means
Internal invariant in baseRows.Scan: the count of FieldDescriptions for the result does not match the count of values in the current row. Not caused by user arguments — it indicates a protocol desync, stale cached statement description, or driver bug, and the rows are marked fatal.
Solutions
- Report upstream with the query and schema if reproducible
- Try a different QueryExecMode to rule out stale cached descriptions
- Close the connection and retry on a fresh one
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at rows.go:241 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/b35dad2f49df44a7.
Report an issue: GitHub.
Appendix: source
Thrown at rows.go:241
}
if rows.resultReader.NextRow() {
rows.rowCount++
rows.values = rows.resultReader.Values()
return true
} else {
rows.Close()
return false
}
}
func (rows *baseRows) Scan(dest ...any) error {
m := rows.typeMap
fieldDescriptions := rows.FieldDescriptions()
values := rows.values
if len(fieldDescriptions) != len(values) {
err := fmt.Errorf("number of field descriptions must equal number of values, got %d and %d", len(fieldDescriptions), len(values))
rows.fatal(err)
return err
}
if len(dest) == 1 {
if rc, ok := dest[0].(RowScanner); ok {
err := rc.ScanRow(rows)
if err != nil {
rows.fatal(err)
}
return err
}
}
if len(fieldDescriptions) != len(dest) {
err := fmt.Errorf("number of field descriptions must equal number of destinations, got %d and %d", len(fieldDescriptions), len(dest))
rows.fatal(err)
return errView on GitHub (pinned to ec1a0befd2)