{"record":{"id":"40bfb1807e5c4cb5","repo":"lionsoul2014/ip2region","slug":"invalid-ip-value-type-s","errorCode":null,"errorMessage":"invalid ip value type %s","messagePattern":"invalid ip value type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/service/ip2region.go","lineNumber":133,"sourceCode":"\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 {\n\t\treturn ip2r.v4InMemSearcher.Search(ipBytes)\n\t}\n\n\t// v4 search is disabled\n\tif ip2r.v4Pool == nil {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/service/ip2region.go#L115-L151","documentation":"Go service Search: the ip argument's dynamic type is neither string nor []byte (e.g. net.IP is not accepted here, nor int/nil), so it cannot be converted to raw IP bytes; the message prints the offending value.","triggerScenarios":"Thrown at binding/golang/service/ip2region.go:133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the IP as a string or a 4/16-byte []byte","Convert net.IP with To4()/To16() to get []byte before calling Search","Add a type switch or generics constraint at your own API boundary"],"exampleFix":null,"handlingStrategy":"type-guard","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"}