{"record":{"id":"d25cb091b91afe79","repo":"lionsoul2014/ip2region","slug":"parse-ip-s-w","errorCode":null,"errorMessage":"parse ip %s: %w","messagePattern":"parse ip (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/service/ip2region.go","lineNumber":128,"sourceCode":"\t\tv6Config = nil\n\t} else {\n\t\tv6Config, err = NewV6Config(VIndexCache, v6XdbPath, 20)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create v6 config: %w\", err)\n\t\t}\n\t}\n\n\treturn NewIp2Region(v4Config, v6Config)\n}\n\nfunc (ip2r *Ip2Region) Search(ip any) (string, error) {\n\tvar err error\n\tvar ipBytes []byte\n\tswitch v := ip.(type) {\n\tcase string:\n\t\tipBytes, err = xdb.ParseIP(v)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"parse ip %s: %w\", v, err)\n\t\t}\n\tcase []byte:\n\t\tipBytes = v\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"invalid ip value type %s\", v)\n\t}\n\n\tif l := len(ipBytes); l == 4 {\n\t\treturn ip2r.v4Search(ipBytes)\n\t} else if l == 16 {\n\t\treturn ip2r.v6Search(ipBytes)\n\t} else {\n\t\treturn \"\", fmt.Errorf(\"invalid byte ip address with len=%d\", l)\n\t}\n}\n\nfunc (ip2r *Ip2Region) v4Search(ipBytes []byte) (string, error) {\n\tif ip2r.v4InMemSearcher != nil {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/service/ip2region.go#L110-L146","documentation":"Go service Search: the string argument failed xdb.ParseIP, meaning it is neither a well-formed IPv4 nor IPv6 literal; the original input and parse error are both wrapped.","triggerScenarios":"Thrown at binding/golang/service/ip2region.go:128 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid IPv4/IPv6 string or pre-parsed 4/16-byte slice","Resolve hostnames to IPs before calling Search","Validate with net.ParseIP at the API boundary"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}