{"record":{"id":"2f278a12a1733d8f","repo":"lionsoul2014/ip2region","slug":"failed-to-load-header-from-s-s","errorCode":null,"errorMessage":"failed to load header from `%s`: %s","messagePattern":"failed to load header from `(.+?)`: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/main.go","lineNumber":94,"sourceCode":"\thandle, err := os.OpenFile(dbPath, os.O_RDONLY, 0600)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"open xdb file `%s`: %w\", dbPath, err)\n\t}\n\n\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\":","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/main.go#L76-L112","documentation":"Go CLI helper: xdb.LoadHeader could not read/parse the 64-byte header from the opened xdb file (short read or invalid header fields); wrapped as %s with the underlying error text.","triggerScenarios":"Thrown at binding/golang/main.go:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the file is a genuine xdb database of at least header size","Re-download the file to rule out truncation","Check disk/read errors on the storage holding the db"],"exampleFix":null,"handlingStrategy":"try-catch","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"}