eclipse-vertx/vert.x · error · io.netty.handler.codec.DecoderException

Invalid content length, or reader index when decoding addres

Error message

Invalid content length, or reader index when decoding address [index: ${data.readerIndex()}, expected length: ${octets}, actual: ${size}].

What it means

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.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/dns/impl/RecordDecoder.java:145

        int index = data.readerIndex();
        while (index < data.writerIndex()) {
          int len = data.getUnsignedByte(index++);
          list.add(data.toString(index, len, CharsetUtil.UTF_8));
          index += len;
        }
        return list;
      } else {
        return null;
      }
    };

    static Function<DnsRecord, String> address(DnsRecordType type, int octets) {
        return record -> {
          if (record.type() == type) {
            ByteBuf data = ((DnsRawRecord)record).content();
            int size = data.readableBytes();
            if (size != octets) {
              throw new DecoderException("Invalid content length, or reader index when decoding address [index: "
                + data.readerIndex() + ", expected length: " + octets + ", actual: " + size + "].");
            }
            byte[] address = new byte[octets];
            data.getBytes(data.readerIndex(), address);
            try {
              return InetAddress.getByAddress(address).getHostAddress();
            } catch (UnknownHostException e) {
              throw new DecoderException("Could not convert address "
                + data.toString(data.readerIndex(), size, CharsetUtil.UTF_8) + " to InetAddress.");
            }
          } else {
            return null;
          }
        };
    }

    /**
     * Retrieves a domain name given a buffer containing a DNS packet. If the

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Treat the DNS response as malformed and retry the lookup against another server
  2. Inspect the reported index/length to confirm truncation or a malformed server response
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at vertx-core/src/main/java/io/vertx/core/dns/impl/RecordDecoder.java:145 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/146c45e7754bd5b7. Report an issue: GitHub.