jackc/pgx · error
cannot scan NULL into *[16]byte
Error message
cannot scan NULL into *[16]byte
What it means
ScanUUID was given a NULL UUID while scanning into *[16]byte, which cannot represent NULL. Null guard in byte16Wrapper; the uuid column was NULL but the destination is a plain [16]byte pointer rather than pgtype.UUID.
Solutions
- Scan into pgtype.UUID or *[16]byte to preserve NULL semantics
- Use COALESCE with a default UUID in the query
- Ensure the column is NOT NULL
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgtype/builtin_wrappers.go:659 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/a499e26005ae1c19.
Report an issue: GitHub.
Appendix: source
Thrown at pgtype/builtin_wrappers.go:659
s := v
hstore[k] = &s
}
return hstore, nil
}
type fmtStringerWrapper struct {
s fmt.Stringer
}
func (w fmtStringerWrapper) TextValue() (Text, error) {
return Text{String: w.s.String(), Valid: true}, nil
}
type byte16Wrapper [16]byte
func (w *byte16Wrapper) ScanUUID(v UUID) error {
if !v.Valid {
return fmt.Errorf("cannot scan NULL into *[16]byte")
}
*w = byte16Wrapper(v.Bytes)
return nil
}
func (w byte16Wrapper) UUIDValue() (UUID, error) {
return UUID{Bytes: [16]byte(w), Valid: true}, nil
}
type byteSliceWrapper []byte
func (w byteSliceWrapper) SkipUnderlyingTypePlan() {}
func (w *byteSliceWrapper) ScanText(v Text) error {
if !v.Valid {
*w = nil
return nil
}View on GitHub (pinned to ec1a0befd2)