jackc/pgx · error
cannot scan NULL into %T
Error message
cannot scan NULL into %T
What it means
Error "cannot scan NULL into %T" thrown in jackc/pgx.
Source
Thrown at pgtype/pgtype.go:412
scanner := dst.(sql.Scanner)
switch {
case src == nil:
// This is necessary because interface value []byte:nil does not equal nil:nil for the binary format path and the
// text format path would be converted to empty string.
return scanner.Scan(nil)
case plan.formatCode == BinaryFormatCode:
return scanner.Scan(src)
default:
return scanner.Scan(string(src))
}
}
type scanPlanString struct{}
func (scanPlanString) Scan(src []byte, dst any) error {
if src == nil {
return fmt.Errorf("cannot scan NULL into %T", dst)
}
p := (dst).(*string)
*p = string(src)
return nil
}
type scanPlanAnyTextToBytes struct{}
func (scanPlanAnyTextToBytes) Scan(src []byte, dst any) error {
dstBuf := dst.(*[]byte)
if src == nil {
*dstBuf = nil
return nil
}
*dstBuf = make([]byte, len(src))
copy(*dstBuf, src)View on GitHub (pinned to ec1a0befd2)
When it happens
Trigger: Thrown at pgtype/pgtype.go:412 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/096f258ce0c37be8.json.
Report an issue: GitHub.