{"record":{"id":"60f700a3bf4f99c5","repo":"apache/cassandra","slug":"not-enough-bytes-to-read-comparator-name-of-compon","errorCode":null,"errorMessage":"Not enough bytes to read comparator name of component %s","messagePattern":"Not enough bytes to read comparator name of component (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java","lineNumber":492,"sourceCode":"        return result;\n    }\n\n    protected ParsedComparator parseComparator(int i, String part)\n    {\n        return new DynamicParsedComparator(part);\n    }\n\n    protected <V> AbstractType<?> validateComparator(int i, V input, ValueAccessor<V> accessor, int offset) throws MarshalException\n    {\n        AbstractType<?> comparator = null;\n        if (accessor.sizeFromOffset(input, offset) < 2)\n            throw new MarshalException(\"Not enough bytes to header of the comparator part of component \" + i);\n        int header = accessor.getShort(input, offset);\n        offset += TypeSizes.SHORT_SIZE;\n        if ((header & 0x8000) == 0)\n        {\n            if (accessor.sizeFromOffset(input, offset) < header)\n                throw new MarshalException(\"Not enough bytes to read comparator name of component \" + i);\n\n            V value = accessor.slice(input, offset, header);\n            String valueStr = null;\n            try\n            {\n                valueStr = accessor.toString(value);\n                comparator = TypeParser.parse(valueStr);\n            }\n            catch (CharacterCodingException ce)\n            {\n                // ByteBufferUtil.string failed.\n                // Log it here and we'll further throw an exception below since comparator == null\n                logger.error(\"Failed when decoding the byte buffer in ByteBufferUtil.string()\", ce);\n            }\n            catch (Exception e)\n            {\n                // parse failed.\n                // Log it here and we'll further throw an exception below since comparator == null","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java#L474-L510","documentation":"In DynamicCompositeType.validateComparator(), when the header short's high bit (0x8000) is clear, the remaining header bits are a length and the comparator class name follows as bytes. If the buffer holds fewer bytes than the header's declared length, the value is malformed and this MarshalException is thrown. It signals truncated or wrongly-encoded composite component data.","triggerScenarios":"A composite component declares a comparator-name length (e.g. 20 bytes for 'org.apache.cassandra...') but the buffer ends before those bytes, during validation of values read from disk or received in a mutation.","commonSituations":"Hand-crafted composite buffers with wrong length fields; partial writes/corruption; tooling that slices composite values at incorrect offsets.","solutions":["Regenerate the value using the type's own decompose/build APIs so lengths match the actual name bytes","Re-read from a healthy replica; run scrub/repair if the stored bytes are corrupt","Audit any custom serializer code that writes the comparator-name length to ensure it uses the encoded byte length"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { type.validate(buffer); } catch (MarshalException e) { log.error(\"Corrupt composite component bytes\", e); }","preventionTips":["Write comparator-name lengths from the encoded byte length of the name, not char count","Validate buffers after any manual slicing of composite values","Keep Cassandra versions consistent across read/write paths"],"tags":["cassandra","composite-type","data-corruption"],"backgroundTag":"schema-validation-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}