jackc/pgx · error
unable to scan OID in text format into
Error message
unable to scan OID %d in text format into %v
What it means
DecodeValue on a text-format composite could not plan a scan for one of its fields: PlanScan returned nil for the field's OID into *any. The composite contains a field type the Map has no scan plan for, so the composite cannot be decoded to a generic map.
Solutions
- Register a codec for the unknown OID in the TypeMap
- Avoid DecodeValue on composites containing unsupported custom types
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/composite.go:238 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/a1a8c660541526ca.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/composite.go:238
default:
return nil, fmt.Errorf("unknown format code %d", format)
}
}
func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil {
return nil, nil
}
switch format {
case TextFormatCode:
scanner := NewCompositeTextScanner(m, src)
values := make(map[string]any, len(c.Fields))
for i := 0; scanner.Next() && i < len(c.Fields); i++ {
var v any
fieldPlan := m.PlanScan(c.Fields[i].Type.OID, TextFormatCode, &v)
if fieldPlan == nil {
return nil, fmt.Errorf("unable to scan OID %d in text format into %v", c.Fields[i].Type.OID, v)
}
err := fieldPlan.Scan(scanner.Bytes(), &v)
if err != nil {
return nil, err
}
values[c.Fields[i].Name] = v
}
if err := scanner.Err(); err != nil {
return nil, err
}
return values, nil
case BinaryFormatCode:
scanner := NewCompositeBinaryScanner(m, src)
values := make(map[string]any, len(c.Fields))View on GitHub (pinned to ec1a0befd2)