prestodb/presto · warning · PrestoException
GENERIC_INTERNAL_ERROR
GENERIC_INTERNAL_ERROR
Error message
Invalid InetAddress length: ${addressLength} What it means
Internal ip_prefix construction validates the raw InetAddress length (4 for IPv4, 16 for IPv6) before applying subnet bounds. Any other length indicates an unexpected address representation, so Presto throws GENERIC_INTERNAL_ERROR. This should be unreachable via normal SQL input and usually indicates a bug or corrupted IPPREFIX/VARCHAR data.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/IpPrefixFunctions.java:136
}
private IpPrefixFunctions() {}
@Description("IP prefix for a given IP address and subnet size")
@ScalarFunction("ip_prefix")
@SqlType(StandardTypes.IPPREFIX)
public static Slice ipPrefix(@SqlType(StandardTypes.IPADDRESS) Slice value, @SqlType(StandardTypes.BIGINT) long subnetSize)
{
InetAddress address = toInetAddress(value);
int addressLength = address.getAddress().length;
if (addressLength == 4) {
checkCondition(0 <= subnetSize && subnetSize <= 32, INVALID_FUNCTION_ARGUMENT, "IPv4 subnet size must be in range [0, 32]");
}
else if (addressLength == 16) {
checkCondition(0 <= subnetSize && subnetSize <= 128, INVALID_FUNCTION_ARGUMENT, "IPv6 subnet size must be in range [0, 128]");
}
else {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Invalid InetAddress length: " + addressLength);
}
return castFromVarcharToIpPrefix(utf8Slice(InetAddresses.toAddrString(address) + "/" + subnetSize));
}
@Description("IP prefix for a given IP address and subnet size")
@ScalarFunction("ip_prefix")
@LiteralParameters("x")
@SqlType(StandardTypes.IPPREFIX)
public static Slice stringIpPrefix(@SqlType("varchar(x)") Slice slice, @SqlType(StandardTypes.BIGINT) long subnetSize)
{
return ipPrefix(castFromVarcharToIpAddress(slice), subnetSize);
}
@Description("Smallest IP address for a given IP prefix")
@ScalarFunction("ip_subnet_min")
@SqlType(StandardTypes.IPADDRESS)
public static Slice ipSubnetMin(@SqlType(StandardTypes.IPPREFIX) Slice value)View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the address string passed to ip_prefix() is a well-formed IPv4 or IPv6 literal.
- If inputs come from a UDF/connector, check that it returns standard IP strings.
- Report as a bug with the offending input if a normal IP string triggers it.
Example fix
// before SELECT ip_prefix(address_col, 24) -- address_col contains non-standard bytes // after SELECT ip_prefix(CAST(address_col AS VARCHAR), 24) -- with validated IP strings
Defensive patterns
Strategy: validation
Validate before calling
-- ensure the input parses to a normal IPv4/IPv6 address first SELECT ip_prefix(CAST(address AS VARCHAR), 24) FROM t WHERE address LIKE '%.%' OR address LIKE '%:%'
Try / catch
// client
try {
executeQuery("SELECT ip_prefix(addr, 24) FROM t");
} catch (QueryFailedException e) {
// GENERIC_INTERNAL_ERROR here indicates a decoder bug; report with the input
} Prevention
- Only feed well-formed IPv4/IPv6 literals into ip_prefix()
- Sanitize connector/UDF outputs that feed address columns
- Report to maintainers if a plain IP string triggers this internal error
When it happens
Trigger: Calling ip_prefix(varchar, integer) where the parsed InetAddress has a byte length other than 4 or 16 — only possible through an internal/decoder bug or corrupted input, since normal parse paths yield only IPv4/IPv6 addresses.
Common situations: Custom address parsing extensions feeding malformed bytes; engine bugs in InetAddress decoding; upstream data corruption reaching an unexpected code path.
Related errors
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
- FUNCTION_IMPLEMENTATION_ERROR
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/066303dc48180a6a.
Report an issue: GitHub.