jackc/pgx · error

uint32

Error message

uint32: %w

What it means

scanPlanBinaryUint32ToUint32 wraps pgio.Uint32Exact: the binary uint32 payload was not exactly 4 bytes, so it cannot be decoded. The wrapped error details the size mismatch.

Solutions

  1. Fail the scan; the binary payload is malformed
  2. Check for truncation/corruption or a custom encoder emitting the wrong width
  3. Verify the value's OID really is uint32 (custom domain)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/uint32.go:284 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/128c796f4fe543a5. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/uint32.go:284

	var n uint32
	err := codecScan(c, m, oid, format, src, &n)
	if err != nil {
		return nil, err
	}
	return n, nil
}

type scanPlanBinaryUint32ToUint32 struct{}

func (scanPlanBinaryUint32ToUint32) Scan(src []byte, dst any) error {
	if src == nil {
		return fmt.Errorf("cannot scan NULL into %T", dst)
	}

	raw, err := pgio.Uint32Exact(src)
	if err != nil {
		return fmt.Errorf("uint32: %w", err)
	}

	p := (dst).(*uint32)
	*p = raw

	return nil
}

type scanPlanBinaryUint32ToUint32Scanner struct{}

func (scanPlanBinaryUint32ToUint32Scanner) Scan(src []byte, dst any) error {
	s, ok := (dst).(Uint32Scanner)
	if !ok {
		return ErrScanTargetTypeChanged
	}

	if src == nil {
		return s.ScanUint32(Uint32{})

View on GitHub (pinned to ec1a0befd2)