{"record":{"id":"146c45e7754bd5b7","repo":"eclipse-vertx/vert.x","slug":"invalid-content-length-or-reader-index-when-decod","errorCode":null,"errorMessage":"Invalid content length, or reader index when decoding address [index: ${data.readerIndex()}, expected length: ${octets}, actual: ${size}].","messagePattern":"Invalid content length, or reader index when decoding address \\[index: (.+?), expected length: (.+?), actual: (.+?)\\]\\.","errorType":"exception","errorClass":"io.netty.handler.codec.DecoderException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/dns/impl/RecordDecoder.java","lineNumber":145,"sourceCode":"        int index = data.readerIndex();\n        while (index < data.writerIndex()) {\n          int len = data.getUnsignedByte(index++);\n          list.add(data.toString(index, len, CharsetUtil.UTF_8));\n          index += len;\n        }\n        return list;\n      } else {\n        return null;\n      }\n    };\n\n    static Function<DnsRecord, String> address(DnsRecordType type, int octets) {\n        return record -> {\n          if (record.type() == type) {\n            ByteBuf data = ((DnsRawRecord)record).content();\n            int size = data.readableBytes();\n            if (size != octets) {\n              throw new DecoderException(\"Invalid content length, or reader index when decoding address [index: \"\n                + data.readerIndex() + \", expected length: \" + octets + \", actual: \" + size + \"].\");\n            }\n            byte[] address = new byte[octets];\n            data.getBytes(data.readerIndex(), address);\n            try {\n              return InetAddress.getByAddress(address).getHostAddress();\n            } catch (UnknownHostException e) {\n              throw new DecoderException(\"Could not convert address \"\n                + data.toString(data.readerIndex(), size, CharsetUtil.UTF_8) + \" to InetAddress.\");\n            }\n          } else {\n            return null;\n          }\n        };\n    }\n\n    /**\n     * Retrieves a domain name given a buffer containing a DNS packet. If the","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/dns/impl/RecordDecoder.java#L127-L163","documentation":"Decoding error for A/AAAA DNS records: the record's raw content length does not match the expected address size (4 bytes for A, 16 for AAAA). The message reports the ByteBuf reader index, the expected octet count, and the actual readable size to pinpoint the malformed record.","triggerScenarios":"Thrown at vertx-core/src/main/java/io/vertx/core/dns/impl/RecordDecoder.java:145 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the DNS response as malformed and retry the lookup against another server","Inspect the reported index/length to confirm truncation or a malformed server response"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}