{"record":{"id":"9e21563399b8b87f","repo":"jackc/pgx","slug":"invalid-net-ipnet","errorCode":null,"errorMessage":"invalid net.IPNet","messagePattern":"invalid net\\.IPNet","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/builtin_wrappers.go","lineNumber":534,"sourceCode":"type 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\n\treturn netip.PrefixFrom(ip, ones), nil\n}\n\ntype netIPWrapper net.IP\n\nfunc (w netIPWrapper) SkipUnderlyingTypePlan() {}\n\nfunc (w *netIPWrapper) ScanNetipPrefix(v netip.Prefix) error {\n\tif !v.IsValid() {\n\t\t*w = nil\n\t\treturn nil\n\t}\n\n\tif v.Addr().BitLen() != v.Bits() {","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/builtin_wrappers.go#L516-L552","documentation":"netIPNetWrapper.NetipPrefixValue guard: the stored net.IPNet holds an IP byte slice of a length netip.AddrFromSlice cannot interpret (not 4 or 16 bytes, e.g. an empty or malformed IP). The invalid IP contents inside the net.IPNet value are the faulty input.","triggerScenarios":"Thrown at pgtype/builtin_wrappers.go:534 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the net.IPNet was built from a valid IPv4/IPv6 address (use net.ParseCIDR)","Store and pass netip.Prefix directly instead of net.IPNet"],"exampleFix":null,"handlingStrategy":"validation","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"}