{"record":{"id":"fcbe8c4467ba40ec","repo":"jackc/pgx","slug":"cannot-scan-infinity-into-time-time-fcbe8c","errorCode":null,"errorMessage":"cannot scan -Infinity into *time.Time","messagePattern":"cannot scan -Infinity into \\*time\\.Time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/zeronull/timestamp.go","lineNumber":30,"sourceCode":"\n// SkipUnderlyingTypePlan implements the [pgtype.SkipUnderlyingTypePlanner] interface.\nfunc (Timestamp) SkipUnderlyingTypePlan() {}\n\n// ScanTimestamp implements the [pgtype.TimestampScanner] interface.\nfunc (ts *Timestamp) ScanTimestamp(v pgtype.Timestamp) error {\n\tif !v.Valid {\n\t\t*ts = Timestamp{}\n\t\treturn nil\n\t}\n\n\tswitch v.InfinityModifier {\n\tcase pgtype.Finite:\n\t\t*ts = Timestamp(v.Time)\n\t\treturn nil\n\tcase pgtype.Infinity:\n\t\treturn fmt.Errorf(\"cannot scan Infinity into *time.Time\")\n\tcase pgtype.NegativeInfinity:\n\t\treturn fmt.Errorf(\"cannot scan -Infinity into *time.Time\")\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid InfinityModifier: %v\", v.InfinityModifier)\n\t}\n}\n\n// TimestampValue implements the [pgtype.TimestampValuer] interface.\nfunc (ts Timestamp) TimestampValue() (pgtype.Timestamp, error) {\n\tif time.Time(ts).IsZero() {\n\t\treturn pgtype.Timestamp{}, nil\n\t}\n\n\treturn pgtype.Timestamp{Time: time.Time(ts), Valid: true}, nil\n}\n\n// Scan implements the [database/sql.Scanner] interface.\nfunc (ts *Timestamp) Scan(src any) error {\n\tif src == nil {\n\t\t*ts = Timestamp{}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/zeronull/timestamp.go#L12-L48","documentation":"ScanTimestamp on zero-null Timestamp rejects a PostgreSQL '-infinity' timestamp: the destination wraps time.Time, which cannot represent negative infinity, so the modifier branch fails instead of silently coercing a finite value.","triggerScenarios":"Thrown at pgtype/zeronull/timestamp.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use pgtype.Timestamp, which carries an InfinityModifier field, instead of the zero-null type","Map -infinity to a sentinel (e.g. time.Time min) with a CASE expression in the query","Filter infinite timestamps out with a WHERE clause"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}