{"record":{"id":"5e827e66350525d9","repo":"lionsoul2014/ip2region","slug":"invalid-version-name-name","errorCode":null,"errorMessage":"invalid version name `${name}`","messagePattern":"invalid version name `(.+?)`","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java","lineNumber":55,"sourceCode":"\n    // compare the two IPs with the current version.\n    // Returns: -1 if ip1 < ip2, 0 if ip1 == ip2, 1 if ip1 > ip2\n    public int ipCompare(byte[] ip1, byte[] ip2) {\n        return ipSubCompare(ip1, ip2, 0);\n    }\n\n    // @see ipCompare\n    public abstract int ipSubCompare(byte[] ip1, byte[] buff, int offset);\n\n    // parse the version from an name\n    public static final Version fromName(String name) throws Exception {\n        final String n = name.toUpperCase();\n        if (n.equals(\"V4\") || n.equals(\"IPV4\")) {\n            return IPv4;\n        } else if (n.equals(\"V6\") || n.equals(\"IPV6\")) {\n            return IPv6;\n        } else {\n            throw new Exception(\"invalid version name `\"+name+\"`\");\n        }\n    }\n\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) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java#L37-L73","documentation":"Java Version.fromName could not map the given (case-insensitive) name to a known IP version; only 'V4'/'IPV4' and 'V6'/'IPV6' are accepted, so any other string hits this sentinel guard.","triggerScenarios":"Thrown at binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the accepted names: 'v4', 'ipv4', 'v6' or 'ipv6' (case-insensitive)","Derive the Version from the xdb header via Version.fromHeader instead of a hand-written name","Whitelist the version name in config parsing before passing it on"],"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"}