{"record":{"id":"ea9a7659f16185b5","repo":"provectus/kafka-ui","slug":"message-buffer-is-not-read-to-the-end-which-is-li","errorCode":null,"errorMessage":"Message buffer is not read to the end, which is likely means message is unrecognized","messagePattern":"Message buffer is not read to the end, which is likely means message is unrecognized","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/serdes/builtin/ConsumerOffsetsSerde.java","lineNumber":297,"sourceCode":"            }\n        );\n      } catch (Throwable e) {\n        bb = bb.rewind();\n        bb.getShort(); // skipping version\n        result = toJson(\n            switch (version) {\n              case 0 -> commitOffsetSchemaV0.read(bb);\n              case 1 -> commitOffsetSchemaV1.read(bb);\n              case 2 -> commitOffsetSchemaV2.read(bb);\n              case 3 -> commitOffsetSchemaV3.read(bb);\n              case 4 -> commitOffsetSchemaV4.read(bb);\n              default -> throw new IllegalArgumentException(\"Unrecognized version: \" + version);\n            }\n        );\n      }\n\n      if (bb.remaining() != 0) {\n        throw new IllegalArgumentException(\n            \"Message buffer is not read to the end, which is likely means message is unrecognized\");\n      }\n      return new DeserializeResult(\n          result,\n          DeserializeResult.Type.JSON,\n          Map.of()\n      );\n    };\n  }\n\n  @SneakyThrows\n  private String toJson(Struct s) {\n    return JSON_MAPPER.writeValueAsString(s);\n  }\n}\n","sourceCodeStart":279,"sourceCodeEnd":313,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/serdes/builtin/ConsumerOffsetsSerde.java#L279-L313","documentation":"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.","triggerScenarios":"valueDeserializer successfully read a version and schema fields, but bb.remaining() != 0 afterwards — the record contains trailing bytes not accounted for by the schema.","commonSituations":"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.","solutions":["Verify the serde is only configured for the __consumer_offsets topic","Compare the raw record against the expected schema; if your broker adds fields, upgrade or patch kafka-ui","Skip/inspect the offending message; this serde should not be used as a general-purpose deserializer"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// after version+schema parse, check leftover bytes yourself: if (bb.remaining() != 0) treatAsUnknown(record);","typeGuard":"boolean fullyConsumed(ByteBuffer bb) { return bb.remaining() == 0; }","tryCatchPattern":"try { result = serde.deserialize(...); } catch (IllegalArgumentException e) { markMessageUnrecognized(record); }","preventionTips":["Never use ConsumerOffsetsSerde on application topics","Sanity-check record payloads against the schema dump for your broker version","Treat leftover-byte records as raw bytes and log them"],"tags":["kafka","serde","binary-protocol"],"backgroundTag":"unexpected-response-shape","analyzedSha":"83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7","analyzedAt":"2026-09-08T04:35:39.002Z","contentChangedAt":"2026-09-08T04:35:39.002Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}