{"record":{"id":"2fbb437ccf8c219a","repo":"lionsoul2014/ip2region","slug":"ip-verison-not-match-xdb-file-s-with-ip-version","errorCode":null,"errorMessage":"ip verison not match: xdb file %s with ip version=%s, as %s expected","messagePattern":"ip verison not match: xdb file (.+?) with ip version=(.+?), as (.+?) expected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/service/config.go","lineNumber":94,"sourceCode":"\terr = xdb.Verify(handle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// 2, load the header\n\theader, err := xdb.LoadHeader(handle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// verify the ip version\n\txIpVersion, err := xdb.VersionFromHeader(header)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif xIpVersion.Id != ipVersion.Id {\n\t\treturn nil, fmt.Errorf(\"ip verison not match: xdb file %s with ip version=%s, as %s expected\", xdbPath, xIpVersion.Name, ipVersion.Name)\n\t}\n\n\t// 3, check and load the vector index buffer\n\tvar vIndex []byte = nil\n\tif cachePolicy == VIndexCache {\n\t\tvIndex, err = xdb.LoadVectorIndex(handle)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// 4, check and load the content buffer\n\tvar cBuffer []byte = nil\n\tif cachePolicy == BufferCache {\n\t\tcBuffer, err = xdb.LoadContent(handle)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/service/config.go#L76-L112","documentation":"Go service config guard: the IP version declared in the xdb header does not match the version the config was created for (e.g. passing an IPv6 database to NewV4Config). Both the file's version and the expected one are reported.","triggerScenarios":"Thrown at binding/golang/service/config.go:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use NewV4Config with an IPv4 xdb and NewV6Config with an IPv6 xdb","Check that the correct db file path is configured for each family","Auto-detect the version via VersionFromHeader when the file's family is unknown"],"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"}