prestodb/presto · error · PrestoException

GENERIC_INTERNAL_ERROR

GENERIC_INTERNAL_ERROR

Error message

Invalid InetAddress length: 

What it means

Defensive guard after IP parsing: the parsed address byte length was neither 4 (IPv4) nor 16 (IPv6), which cannot happen for well-formed InetAddresses output. This is an internal consistency check indicating a malformed/unexpected address representation; the offending text is appended.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/type/IpAddressOperators.java:147

        try {
            address = InetAddresses.forString(slice.toStringUtf8()).getAddress();
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(INVALID_CAST_ARGUMENT, "Cannot cast value to IPADDRESS: " + slice.toStringUtf8());
        }

        byte[] bytes;
        if (address.length == 4) {
            bytes = new byte[16];
            bytes[10] = (byte) 0xff;
            bytes[11] = (byte) 0xff;
            arraycopy(address, 0, bytes, 12, 4);
        }
        else if (address.length == 16) {
            bytes = address;
        }
        else {
            throw new PrestoException(GENERIC_INTERNAL_ERROR, "Invalid InetAddress length: " + address.length);
        }

        return wrappedBuffer(bytes);
    }

    @ScalarOperator(CAST)
    @SqlType(StandardTypes.VARCHAR)
    public static Slice castFromIpAddressToVarchar(@SqlType(StandardTypes.IPADDRESS) Slice slice)
    {
        try {
            return utf8Slice(InetAddresses.toAddrString(InetAddress.getByAddress(slice.getBytes())));
        }
        catch (UnknownHostException e) {
            throw new PrestoException(INVALID_CAST_ARGUMENT, "Invalid IP address binary length: " + slice.length(), e);
        }
    }

    @ScalarOperator(CAST)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use standard IPv4/IPv6 literal text as cast input
  2. Report as a Presto bug if the input is a well-formed address
  3. Sanitize upstream data producing odd address encodings
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-main-base/src/main/java/com/facebook/presto/type/IpAddressOperators.java:147 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/dc6bff1cf526cffb. Report an issue: GitHub.