jackc/pgx · error

cannot scan NULL into %#v

Error message

cannot scan NULL into %#v

What it means

Error "cannot scan NULL into %#v" thrown in jackc/pgx.

Source

Thrown at pgtype/builtin_wrappers.go:736

	return w.s == nil
}

func (w structWrapper) Index(i int) any {
	if i >= len(w.exportedFields) {
		return fmt.Errorf("%#v only has %d public fields - %d is out of bounds", w.s, len(w.exportedFields), i)
	}

	return w.exportedFields[i].Interface()
}

// ptrStructWrapper implements CompositeIndexScanner for a pointer to a struct.
type ptrStructWrapper struct {
	s              any
	exportedFields []reflect.Value
}

func (w *ptrStructWrapper) ScanNull() error {
	return fmt.Errorf("cannot scan NULL into %#v", w.s)
}

func (w *ptrStructWrapper) ScanIndex(i int) any {
	if i >= len(w.exportedFields) {
		return fmt.Errorf("%#v only has %d public fields - %d is out of bounds", w.s, len(w.exportedFields), i)
	}

	return w.exportedFields[i].Addr().Interface()
}

type anySliceArrayReflect struct {
	slice reflect.Value
}

func (a anySliceArrayReflect) Dimensions() []ArrayDimension {
	if a.slice.IsNil() {
		return nil
	}

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgtype/builtin_wrappers.go:736 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: /data/errors/9d06cb245602a4de.json. Report an issue: GitHub.