provectus/kafka-ui · error · IllegalArgumentException

Message buffer is not read to the end, which is likely…

Error message

Message buffer is not read to the end, which is likely means message is unrecognized

What it means

After reading the version and the record fields, ConsumerOffsetsSerde expects the byte buffer to be fully consumed; leftover bytes mean the payload did not match any known __consumer_offsets schema. To avoid emitting misleading JSON, the serde throws IllegalArgumentException indicating the message is likely unrecognized.

Solutions

  1. Verify the serde is only configured for the __consumer_offsets topic
  2. Compare the raw record against the expected schema; if your broker adds fields, upgrade or patch kafka-ui
  3. Skip/inspect the offending message; this serde should not be used as a general-purpose deserializer
Defensive patterns

Strategy: try-catch

Validate before calling

// after version+schema parse, check leftover bytes yourself: if (bb.remaining() != 0) treatAsUnknown(record);

Type guard

boolean fullyConsumed(ByteBuffer bb) { return bb.remaining() == 0; }

Try / catch

try { result = serde.deserialize(...); } catch (IllegalArgumentException e) { markMessageUnrecognized(record); }

Prevention

When it happens

Trigger: valueDeserializer successfully read a version and schema fields, but bb.remaining() != 0 afterwards — the record contains trailing bytes not accounted for by the schema.

Common situations: Serde applied to a random non-__consumer_offsets topic whose data accidentally passes the version check; broker schema changes appending extra fields; truncated/mutated records.

Related errors


AI-assisted analysis of provectus/kafka-ui@83b5a60cc0 (2026-09-08). Data as JSON: /api/errors/ea9a7659f16185b5. Report an issue: GitHub.

Appendix: source

Thrown at kafka-ui-api/src/main/java/com/provectus/kafka/ui/serdes/builtin/ConsumerOffsetsSerde.java:297

            }
        );
      } catch (Throwable e) {
        bb = bb.rewind();
        bb.getShort(); // skipping version
        result = toJson(
            switch (version) {
              case 0 -> commitOffsetSchemaV0.read(bb);
              case 1 -> commitOffsetSchemaV1.read(bb);
              case 2 -> commitOffsetSchemaV2.read(bb);
              case 3 -> commitOffsetSchemaV3.read(bb);
              case 4 -> commitOffsetSchemaV4.read(bb);
              default -> throw new IllegalArgumentException("Unrecognized version: " + version);
            }
        );
      }

      if (bb.remaining() != 0) {
        throw new IllegalArgumentException(
            "Message buffer is not read to the end, which is likely means message is unrecognized");
      }
      return new DeserializeResult(
          result,
          DeserializeResult.Type.JSON,
          Map.of()
      );
    };
  }

  @SneakyThrows
  private String toJson(Struct s) {
    return JSON_MAPPER.writeValueAsString(s);
  }
}

View on GitHub (pinned to 83b5a60cc0)