{"record":{"id":"57df7b12266e7c4b","repo":"provectus/kafka-ui","slug":"uuid-data-should-be-16-bytes-but-it-is-data-len","errorCode":null,"errorMessage":"UUID data should be 16 bytes, but it is ${data.length}","messagePattern":"UUID data should be 16 bytes, but it is (.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/serdes/builtin/UuidBinarySerde.java","lineNumber":71,"sourceCode":"    return input -> {\n      UUID uuid = UUID.fromString(input);\n      ByteBuffer bb = ByteBuffer.wrap(new byte[16]);\n      if (mostSignificantBitsFirst) {\n        bb.putLong(uuid.getMostSignificantBits());\n        bb.putLong(uuid.getLeastSignificantBits());\n      } else {\n        bb.putLong(uuid.getLeastSignificantBits());\n        bb.putLong(uuid.getMostSignificantBits());\n      }\n      return bb.array();\n    };\n  }\n\n  @Override\n  public Deserializer deserializer(String topic, Target type) {\n    return (headers, data) -> {\n      if (data.length != 16) {\n        throw new ValidationException(\"UUID data should be 16 bytes, but it is \" + data.length);\n      }\n      ByteBuffer bb = ByteBuffer.wrap(data);\n      long msb = bb.getLong();\n      long lsb = bb.getLong();\n      UUID uuid = mostSignificantBitsFirst ? new UUID(msb, lsb) : new UUID(lsb, msb);\n      return new DeserializeResult(\n          uuid.toString(),\n          DeserializeResult.Type.STRING,\n          Map.of()\n      );\n    };\n  }\n}\n","sourceCodeStart":53,"sourceCodeEnd":85,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/serdes/builtin/UuidBinarySerde.java#L53-L85","documentation":"UuidBinarySerde deserializes 16-byte UUIDs (MSB-first or LSB-first per configuration). If the message payload is not exactly 16 bytes it cannot be a binary UUID, so ValidationException is thrown with the actual byte length.","triggerScenarios":"deserializer invoked on a Kafka record whose byte array length != 16 (empty payload, string-encoded UUID, or other binary format).","commonSituations":"Applying the UUID serde to topics with mixed or non-UUID payloads; producer sending UUID as a 36-char string instead of 16 raw bytes; tombstone/null or truncated messages.","solutions":["Ensure producers write raw 16-byte UUIDs (UUID.nameUUIDFromBytes / writeLong msb+lsb), not string forms","Restrict the serde's topic pattern to topics that truly contain binary UUIDs","Check mostSignificantBitsFirst configuration matches the producer's byte order"],"exampleFix":"// before (producer)\nbyte[] payload = uuid.toString().getBytes();\n// after (producer)\nByteBuffer bb = ByteBuffer.allocate(16);\nbb.putLong(uuid.getMostSignificantBits());\nbb.putLong(uuid.getLeastSignificantBits());\nbyte[] payload = bb.array();","handlingStrategy":"validation","validationCode":"if (data == null || data.length != 16) { /* skip topic or use fallback serde */ }","typeGuard":"boolean isBinaryUuid(byte[] data) { return data != null && data.length == 16; }","tryCatchPattern":"try { result = serde.deserialize(headers, data); } catch (ValidationException e) { result = fallbackSerde.deserialize(headers, data); }","preventionTips":["Producers must send raw 16-byte UUIDs, not string representations","Configure serde topic patterns narrowly to UUID-only topics","Confirm byte order (mostSignificantBitsFirst) with the producer team"],"tags":["uuid","serde","validation"],"backgroundTag":"invalid-argument-format","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"}