jackc/pgx · error

invalid InfinityModifier

Error message

invalid InfinityModifier: %v

What it means

Defensive default branch in ScanTimestamp: the pgtype.Timestamp carried an InfinityModifier outside {Finite, Infinity, NegativeInfinity}, which cannot be produced by wire decoding. Firing indicates an uninitialized or corrupted pgtype.Timestamp, not a data-range issue.

Solutions

  1. Report upstream as a bug, including the modifier value and query
  2. Ensure hand-built pgtype.Timestamp values only use documented InfinityModifier constants
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/zeronull/timestamp.go:32 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/41cf3b27dc3956f2. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/zeronull/timestamp.go:32

func (Timestamp) SkipUnderlyingTypePlan() {}

// ScanTimestamp implements the [pgtype.TimestampScanner] interface.
func (ts *Timestamp) ScanTimestamp(v pgtype.Timestamp) error {
	if !v.Valid {
		*ts = Timestamp{}
		return nil
	}

	switch v.InfinityModifier {
	case pgtype.Finite:
		*ts = Timestamp(v.Time)
		return nil
	case pgtype.Infinity:
		return fmt.Errorf("cannot scan Infinity into *time.Time")
	case pgtype.NegativeInfinity:
		return fmt.Errorf("cannot scan -Infinity into *time.Time")
	default:
		return fmt.Errorf("invalid InfinityModifier: %v", v.InfinityModifier)
	}
}

// TimestampValue implements the [pgtype.TimestampValuer] interface.
func (ts Timestamp) TimestampValue() (pgtype.Timestamp, error) {
	if time.Time(ts).IsZero() {
		return pgtype.Timestamp{}, nil
	}

	return pgtype.Timestamp{Time: time.Time(ts), Valid: true}, nil
}

// Scan implements the [database/sql.Scanner] interface.
func (ts *Timestamp) Scan(src any) error {
	if src == nil {
		*ts = Timestamp{}
		return nil
	}

View on GitHub (pinned to ec1a0befd2)