jackc/pgx · error
cannot scan (OID ) in format into %T
Error message
cannot scan %s (OID %d) in %v format into %T
What it means
This is the error produced by scanPlanFail, the plan Map.PlanScan returns when no codec can handle the combination of PostgreSQL type, wire format, and destination Go type. It names the type (or 'unknown type' if the OID isn't registered), its OID, the format, and the destination type, so the unsupported leg of the lookup is identifiable.
Solutions
- Scan into a supported Go type for that column (e.g. *string for unknown OIDs)
- Register a custom codec or type mapping for the OID with RegisterType/TryWrapEncodePlanFunc
- Cast the column in SQL to a type with a known codec
- Scan into pgtype's generic types (Text, Numeric) or use driver.Value
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at pgtype/pgtype.go:483 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/7c9dc0f1b8692ecf.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/pgtype.go:483
var format string
switch plan.formatCode {
case TextFormatCode:
format = "text"
case BinaryFormatCode:
format = "binary"
default:
format = fmt.Sprintf("unknown %d", plan.formatCode)
}
var dataTypeName string
if t, ok := plan.m.TypeForOID(plan.oid); ok {
dataTypeName = t.Name
} else {
dataTypeName = "unknown type"
}
return fmt.Errorf("cannot scan %s (OID %d) in %v format into %T", dataTypeName, plan.oid, format, dst)
}
// TryWrapScanPlanFunc is a function that tries to create a wrapper plan for target. If successful it returns a plan
// that will convert the target passed to Scan and then call the next plan. nextTarget is target as it will be converted
// by plan. It must be used to find another suitable ScanPlan. When it is found SetNext must be called on plan for it
// to be usabled. ok indicates if a suitable wrapper was found.
type TryWrapScanPlanFunc func(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool)
type pointerPointerScanPlan struct {
dstType reflect.Type
next ScanPlan
}
func (plan *pointerPointerScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *pointerPointerScanPlan) Scan(src []byte, dst any) error {
dstValue := reflect.ValueOf(dst)
if dstValue.Kind() != reflect.Pointer || dstValue.IsNil() {View on GitHub (pinned to ec1a0befd2)