lionsoul2014/ip2region · error · Exception
invalid version name `${name}`
Error message
invalid version name `${name}` What it means
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.
Source
Thrown at binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java:55
// compare the two IPs with the current version.
// Returns: -1 if ip1 < ip2, 0 if ip1 == ip2, 1 if ip1 > ip2
public int ipCompare(byte[] ip1, byte[] ip2) {
return ipSubCompare(ip1, ip2, 0);
}
// @see ipCompare
public abstract int ipSubCompare(byte[] ip1, byte[] buff, int offset);
// parse the version from an name
public static final Version fromName(String name) throws Exception {
final String n = name.toUpperCase();
if (n.equals("V4") || n.equals("IPV4")) {
return IPv4;
} else if (n.equals("V6") || n.equals("IPV6")) {
return IPv6;
} else {
throw new Exception("invalid version name `"+name+"`");
}
}
// parse the version from header
public static final Version fromHeader(Header header) throws XdbException {
// Old 2.0 structure with IPv4 supports ONLY.
if (header.version == Searcher.STRUCTURE_20) {
return IPv4;
}
// structure 3.0 after IPv6 supporting
if (header.version != Searcher.STRUCTURE_30) {
throw new XdbException("invalid xdb structure version `"+header.version+"`");
}
if (header.ipVersion == IPv4VersionNo) {
return IPv4;
} else if (header.ipVersion == IPv6VersionNo) {View on GitHub (pinned to c1a1fc7d59)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at binding/java/src/main/java/org/lionsoul/ip2region/xdb/Version.java:55 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02).
Data as JSON: /api/errors/5e827e66350525d9.
Report an issue: GitHub.