{"record":{"id":"30cb9f4a2dbecc7b","repo":"lionsoul2014/ip2region","slug":"failed-to-detect-ip-version-from-s-s","errorCode":null,"errorMessage":"failed to detect IP version from `%s`: %s","messagePattern":"failed to detect IP version from `(.+?)`: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/main.go","lineNumber":99,"sourceCode":"\tdefer handle.Close()\n\n\t// verify the xdb file\n\t// @Note: do NOT call it every time you create a searcher since this will slow down the search response.\n\t// @see the util.Verify function for details.\n\terr = xdb.Verify(handle)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"xdb verify: %w\", err)\n\t}\n\n\t// auto-detect the ip version from the xdb header\n\theader, err := xdb.LoadHeader(handle)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load header from `%s`: %s\", dbPath, err)\n\t}\n\n\tversion, err := xdb.VersionFromHeader(header)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to detect IP version from `%s`: %s\", dbPath, err)\n\t}\n\n\tswitch cachePolicy {\n\tcase \"nil\", \"file\":\n\t\treturn xdb.NewWithFileOnly(version, dbPath)\n\tcase \"vectorIndex\":\n\t\tvIndex, err := xdb.LoadVectorIndexFromFile(dbPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load vector index from `%s`: %w\", dbPath, err)\n\t\t}\n\n\t\treturn xdb.NewWithVectorIndex(version, dbPath, vIndex)\n\tcase \"content\":\n\t\tcBuff, err := xdb.LoadContentFromFile(dbPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load content from '%s': %w\", dbPath, err)\n\t\t}\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/main.go#L81-L117","documentation":"Go CLI helper: xdb.VersionFromHeader rejected the header — the structure version is not 2.0/3.0 or the ipVersion field is unknown, so the IP family of the database cannot be auto-detected.","triggerScenarios":"Thrown at binding/golang/main.go:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid xdb whose header carries a recognized structure and ip version","Regenerate the database with the current maker","Manually construct the searcher with an explicit version if the header is known-good but nonstandard"],"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"}