{"record":{"id":"bec2f9549a66157e","repo":"apache/cassandra","slug":"corrupted-input-expected-byte-1-2-3-4-or-5-re","errorCode":null,"errorMessage":"Corrupted input: expected byte 1, 2, 3, 4 or 5; received ","messagePattern":"Corrupted input: expected byte 1, 2, 3, 4 or 5; received ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/serializers/KeySerializers.java","lineNumber":385,"sourceCode":"                case 1: kind = UnseekablesKind.RoutingKeys; result = (RS)routingKeys.deserialize(in); break;\n                case 2: kind = UnseekablesKind.PartialKeyRoute; result = (RS)partialKeyRoute.deserialize(in); break;\n                case 3: kind = UnseekablesKind.FullKeyRoute; result = (RS)fullKeyRoute.deserialize(in); break;\n                case 4: kind = UnseekablesKind.RoutingRanges; result = (RS)ranges.deserialize(in); break;\n                case 5: kind = UnseekablesKind.PartialRangeRoute; result = (RS)partialRangeRoute.deserialize(in); break;\n                case 6: kind = UnseekablesKind.FullRangeRoute; result = (RS)fullRangeRoute.deserialize(in); break;\n            }\n            Invariants.require(permitted.contains(kind));\n            return result;\n        }\n\n        public RS deserializeSubset(Unseekables<?> superset, DataInputPlus in) throws IOException\n        {\n            byte b = in.readByte();\n            UnseekablesKind kind;\n            RS result;\n            switch (b)\n            {\n                default: throw new IOException(\"Corrupted input: expected byte 1, 2, 3, 4 or 5; received \" + b);\n                case 1: kind = UnseekablesKind.RoutingKeys; result = (RS)routingKeys.deserializeSubset((AbstractUnseekableKeys) superset, in); break;\n                case 2: kind = UnseekablesKind.PartialKeyRoute; result = (RS)partialKeyRoute.deserializeSubset((AbstractUnseekableKeys) superset, in); break;\n                case 3: kind = UnseekablesKind.FullKeyRoute; result = (RS)fullKeyRoute.deserializeSubset((AbstractUnseekableKeys) superset, in); break;\n                case 4: kind = UnseekablesKind.RoutingRanges; result = (RS)ranges.deserializeSubset((AbstractRanges) superset, in); break;\n                case 5: kind = UnseekablesKind.PartialRangeRoute; result = (RS)partialRangeRoute.deserializeSubset((AbstractRanges) superset, in); break;\n                case 6: kind = UnseekablesKind.FullRangeRoute; result = (RS)fullRangeRoute.deserializeSubset((AbstractRanges) superset, in); break;\n            }\n            Invariants.require(permitted.contains(kind));\n            return result;\n        }\n\n        public void skip(DataInputPlus in) throws IOException\n        {\n            countAndSkip(in);\n        }\n\n        public void skip(UnseekablesKind kind, DataInputPlus in) throws IOException\n        {","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/serializers/KeySerializers.java#L367-L403","documentation":"deserializeSubset decodes an Unseekables that is a subset of a known superset, using the same 1-6 kind byte scheme. An unrecognized byte throws IOException, meaning the payload is not a valid serialized Unseekables subset — corruption, misalignment, or encoder/decoder version mismatch.","triggerScenarios":"deserializeSubset(superset, in) reads a kind byte outside 1..6 when decoding a subset of Unseekables/Route relative to a superset.","commonSituations":"Rolling-upgrade version skew; corrupted or truncated network data; a preceding read failure leaving the stream mid-record; tests passing fabricated bytes.","solutions":["Ensure all nodes use compatible Accord serializer versions (complete rolling upgrade).","Inspect the received byte against UnseekablesKind values to find the encoding mismatch.","Check the connection for earlier deserialization errors that misaligned the stream and reset it if found.","Update the switch when new UnseekablesKind values are introduced."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Unseekables<?, ?> subset = serializer.deserializeSubset(superset, in);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Corrupted input\")) {\n        logger.warn(\"Corrupt Unseekables subset payload; dropping message\", e);\n    } else throw e;\n}","preventionTips":["Keep serializer versions aligned across the cluster.","Validate subset/superset pairing in tests (same kind family).","Reset connections after any parse failure to avoid cascading misreads."],"tags":["serialization","deserialization","accord","corrupted-input"],"backgroundTag":"invalid-enum-value","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"}