{"record":{"id":"2dc9fbcbd404c371","repo":"prestodb/presto","slug":"generic-internal-error-2dc9fb","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Invalid InetAddress length: ","messagePattern":"Invalid InetAddress length: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/IpAddressDecoder.java","lineNumber":85,"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","sourceCodeStart":67,"sourceCodeEnd":91,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/IpAddressDecoder.java#L67-L91","documentation":"castToIpAddress converts the parsed InetAddress to a 4- or 16-byte representation and throws GENERIC_INTERNAL_ERROR for any other byte length. Since InetAddresses.forString only ever returns 4 or 16 bytes, this is a defensive assertion indicating an unexpected internal state rather than user data problems.","triggerScenarios":"In practice unreachable: it fires only if castToIpAddress somehow obtains an InetAddress whose getAddress() length is neither 4 nor 16, i.e. a future/alternate InetAddress implementation returning an unexpected size.","commonSituations":"Essentially never hit by users; would appear only after a Guava/JDK behavior change or patched InetAddresses behavior, or if the decoder were modified to use a different parsing path.","solutions":["Treat it as a bug: report it with the value being decoded and the Guava/JDK versions in use.","Check Guava version compatibility; upgrade or downgrade facebook/presto-elasticsearch and Guava to a known-good combination.","As a workaround, map the field as VARCHAR and cast in SQL to bypass castToIpAddress."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { runQuery(); } catch (PrestoException e) { if (e.getErrorCode().getCode() == GENERIC_INTERNAL_ERROR) { fileBugWithQueryAndData(); } throw e; }","preventionTips":["Pin known-good Guava and connector versions; test upgrades in staging.","Treat this error as a bug report trigger, not user error.","Avoid patching InetAddresses-based parsing paths in the decoder."],"tags":["elasticsearch","presto","internal-error","invariant"],"backgroundTag":"internal-invariant-violation","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"}