{"record":{"id":"dc6bff1cf526cffb","repo":"prestodb/presto","slug":"generic-internal-error-dc6bff","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Invalid InetAddress length: ","messagePattern":"Invalid InetAddress length: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/type/IpAddressOperators.java","lineNumber":147,"sourceCode":"        try {\n            address = InetAddresses.forString(slice.toStringUtf8()).getAddress();\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(INVALID_CAST_ARGUMENT, \"Cannot cast value to IPADDRESS: \" + slice.toStringUtf8());\n        }\n\n        byte[] bytes;\n        if (address.length == 4) {\n            bytes = new byte[16];\n            bytes[10] = (byte) 0xff;\n            bytes[11] = (byte) 0xff;\n            arraycopy(address, 0, bytes, 12, 4);\n        }\n        else if (address.length == 16) {\n            bytes = address;\n        }\n        else {\n            throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Invalid InetAddress length: \" + address.length);\n        }\n\n        return wrappedBuffer(bytes);\n    }\n\n    @ScalarOperator(CAST)\n    @SqlType(StandardTypes.VARCHAR)\n    public static Slice castFromIpAddressToVarchar(@SqlType(StandardTypes.IPADDRESS) Slice slice)\n    {\n        try {\n            return utf8Slice(InetAddresses.toAddrString(InetAddress.getByAddress(slice.getBytes())));\n        }\n        catch (UnknownHostException e) {\n            throw new PrestoException(INVALID_CAST_ARGUMENT, \"Invalid IP address binary length: \" + slice.length(), e);\n        }\n    }\n\n    @ScalarOperator(CAST)","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/type/IpAddressOperators.java#L129-L165","documentation":"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.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/type/IpAddressOperators.java:147 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use standard IPv4/IPv6 literal text as cast input","Report as a Presto bug if the input is a well-formed address","Sanitize upstream data producing odd address encodings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}