{"record":{"id":"859e1243a63348d1","repo":"lionsoul2014/ip2region","slug":"invalid-ip-version-number-header-ipversion","errorCode":null,"errorMessage":"invalid ip version number `${header.ipVersion}`","messagePattern":"invalid ip version number `(.+?)`","errorType":"exception","errorClass":"XdbException","httpStatus":null,"severity":"error","filePath":"binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java","lineNumber":76,"sourceCode":"\n    // parse the version from header\n    public static final Version fromHeader(Header header) throws XdbException {\n        // Old 2.0 structure with IPv4 supports ONLY.\n        if (header.version == Searcher.STRUCTURE_20) {\n            return IPv4;\n        }\n\n        // structure 3.0 after IPv6 supporting\n        if (header.version != Searcher.STRUCTURE_30) {\n            throw new XdbException(\"invalid xdb structure version `\"+header.version+\"`\");\n        }\n\n        if (header.ipVersion == IPv4VersionNo) {\n            return IPv4;\n        } else if (header.ipVersion == IPv6VersionNo) {\n            return IPv6;\n        } else {\n            throw new XdbException(\"invalid ip version number `\" + header.ipVersion + \"`\");\n        }\n    }\n\n    @Override public String toString() {\n        return String.format(\"{Id:%d, Name:%s, Bytes:%d, IndexSize: %d}\", id, name, bytes, segmentIndexSize);\n    }\n}","sourceCodeStart":58,"sourceCodeEnd":83,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java#L58-L83","documentation":"Java Version.fromHeader: the structure version is 3.0 but the header's ipVersion field matches neither the IPv4 nor the IPv6 version number, so the address family of the database cannot be determined; the header is corrupt or from an unsupported xdb variant.","triggerScenarios":"Thrown at binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an xdb file generated by a maker that writes a valid ipVersion header field","Re-download/regenerate the database to eliminate corruption","If you control the maker, ensure the header encodes 1 (IPv4) or 2 (IPv6) as expected"],"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"}