{"id":"52aaa6e87fba2f04","repo":"jackc/pgx","slug":"cannot-scan-null-into-net-ipnet","errorCode":null,"errorMessage":"cannot scan NULL into *net.IPNet","messagePattern":"cannot scan NULL into \\*net\\.IPNet","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/builtin_wrappers.go","lineNumber":520,"sourceCode":"func (w *durationWrapper) ScanInterval(v Interval) error {\n\tif !v.Valid {\n\t\treturn fmt.Errorf(\"cannot scan NULL into *time.Interval\")\n\t}\n\n\tus := int64(v.Months)*microsecondsPerMonth + int64(v.Days)*microsecondsPerDay + v.Microseconds\n\t*w = durationWrapper(time.Duration(us) * time.Microsecond)\n\treturn nil\n}\n\nfunc (w durationWrapper) IntervalValue() (Interval, error) {\n\treturn Interval{Microseconds: int64(w) / 1000, Valid: true}, nil\n}\n\ntype netIPNetWrapper net.IPNet\n\nfunc (w *netIPNetWrapper) ScanNetipPrefix(v netip.Prefix) error {\n\tif !v.IsValid() {\n\t\treturn fmt.Errorf(\"cannot scan NULL into *net.IPNet\")\n\t}\n\n\t*w = netIPNetWrapper{\n\t\tIP:   v.Addr().AsSlice(),\n\t\tMask: net.CIDRMask(v.Bits(), v.Addr().BitLen()),\n\t}\n\n\treturn nil\n}\n\nfunc (w netIPNetWrapper) NetipPrefixValue() (netip.Prefix, error) {\n\tip, ok := netip.AddrFromSlice(w.IP)\n\tif !ok {\n\t\treturn netip.Prefix{}, errors.New(\"invalid net.IPNet\")\n\t}\n\n\tones, _ := w.Mask.Size()\n","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/builtin_wrappers.go#L502-L538","documentation":"Error \"cannot scan NULL into *net.IPNet\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/builtin_wrappers.go:520 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}