{"record":{"id":"0d4770b54f6af317","repo":"apache/cassandra","slug":"not-enough-bytes-to-read-a-s-0d4770","errorCode":null,"errorMessage":"Not enough bytes to read a %s","messagePattern":"Not enough bytes to read a (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/VectorType.java","lineNumber":548,"sourceCode":"                result.add(elementSerializer.deserialize(bb, accessor));\n            }\n            checkConsumedFully(input, accessor, offset);\n\n            return result;\n        }\n\n        @Override\n        public <V> void validate(V input, ValueAccessor<V> accessor) throws MarshalException\n        {\n            if (accessor.isEmpty(input))\n                rejectNullOrEmptyValue();\n\n            int offset = 0;\n            int elementSize = elementType.valueLengthIfFixed();\n\n            int expectedSize = elementSize * dimension;\n            if (accessor.size(input) < expectedSize)\n                throw new MarshalException(\"Not enough bytes to read a \" + asCQL3Type());\n\n            for (int i = 0; i < dimension; i++)\n            {\n                V bb = accessor.slice(input, offset, elementSize);\n                offset += elementSize;\n                elementSerializer.validate(bb, accessor);\n            }\n            checkConsumedFully(input, accessor, offset);\n        }\n    }\n\n    private class VariableLengthSerializer extends VectorSerializer\n    {\n        private VariableLengthSerializer()\n        {\n        }\n\n        @Override","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/VectorType.java#L530-L566","documentation":"The FixedLengthSerializer's validate path computes expectedSize = elementSize * dimension and throws this MarshalException if the input buffer is smaller than that. Fixed-length vector values must carry exactly the full sized payload.","triggerScenarios":"Validating a vector<fixed_length_type, N> value whose ByteBuffer is shorter than N * elementSize; passing an empty buffer; dimension in the type is larger than the data written.","commonSituations":"Driver/application sending truncated vectors; schema dimension changed after data was written; tests with undersized buffers; corrupted on-disk data.","solutions":["Ensure input has at least elementSize * dimension bytes before calling validate","Reconcile the column's dimension with the actual data (ALTER to correct dimension or rewrite data)","Scrub or restore SSTables if the truncation comes from storage"],"exampleFix":"// before\nvectorType.validate(byteBuffer); // 8 bytes for vector<int, 4>\n// after\nif (byteBuffer.remaining() < 4 * 4) throw new IllegalArgumentException(\"vector<int,4> needs 16 bytes\");\nvectorType.validate(byteBuffer);","handlingStrategy":"validation","validationCode":"int expected = elementSize * dimension;\nif (input == null || accessor.size(input) < expected) throw new IllegalArgumentException(\"vector payload too short\");","typeGuard":null,"tryCatchPattern":"try { vectorType.validate(input); } catch (MarshalException e) { log.error(\"invalid vector value: {}\", e.getMessage()); throw new IllegalArgumentException(e); }","preventionTips":["Ensure writers serialize exactly dimension elements","Verify data after restores/migrations from older clusters","Keep Cassandra versions consistent across the cluster"],"tags":["cassandra","serialization","vector-type","size-validation"],"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-17T15:17:12.973Z"}