{"record":{"id":"1d41165818c7054a","repo":"apache/cassandra","slug":"corrupted-input-expected-byte-1-or-2-received","errorCode":null,"errorMessage":"Corrupted input: expected byte 1 or 2, received \" + b","messagePattern":"Corrupted input: expected byte 1 or 2, received \" \\+ b","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/serializers/KeySerializers.java","lineNumber":534,"sourceCode":"                default: throw new AssertionError();\n                case Key:\n                    out.writeByte(0);\n                    PartitionKey.serializer.serialize((PartitionKey) seekable, out);\n                    break;\n                case Range:\n                    out.writeByte(1);\n                    TokenRange.serializer.serialize((TokenRange) seekable, out);\n                    break;\n            }\n        }\n\n        @Override\n        public Seekable deserialize(DataInputPlus in) throws IOException\n        {\n            byte b = in.readByte();\n            switch (b)\n            {\n                default: throw new IOException(\"Corrupted input: expected byte 1 or 2, received \" + b);\n                case 0: return PartitionKey.serializer.deserialize(in);\n                case 1: return TokenRange.serializer.deserialize(in);\n            }\n        }\n\n        @Override\n        public void skip(DataInputPlus in) throws IOException\n        {\n            byte b = in.readByte();\n            switch (b)\n            {\n                default: throw new IOException(\"Corrupted input: expected byte 1 or 2, received \" + b);\n                case 0: PartitionKey.serializer.skip(in); break;\n                case 1: TokenRange.serializer.skip(in); break;\n            }\n        }\n\n        @Override","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/serializers/KeySerializers.java#L516-L552","documentation":"Seekable.serializer.deserialize reads one tag byte: 0 decodes a PartitionKey, 1 decodes a TokenRange. Any other byte throws IOException with the received value. The message text 'expected byte 1 or 2' is stale — the handled cases are actually 0 and 1. This error means the stream does not contain a valid serialized Seekable.","triggerScenarios":"deserialize(DataInputPlus) reads a tag byte other than 0 or 1 when decoding a Seekable, e.g. inside Accord transaction/command deserialization.","commonSituations":"Corrupted or truncated network payloads; encoder/decoder version skew in a rolling upgrade; stream misaligned by a previous parse failure; test fixtures with wrong tag bytes.","solutions":["Confirm all nodes run compatible versions so the Seekable tag encoding matches.","Log the received byte; note valid values are 0 (PartitionKey) and 1 (TokenRange) despite the message text.","Check the connection for earlier deserialization errors that may have shifted the read position; reset if found.","Fix the message string to say 'expected byte 0 or 1' for accurate debugging."],"exampleFix":"// before\ndefault: throw new IOException(\"Corrupted input: expected byte 1 or 2, received \" + b);\n// after\ndefault: throw new IOException(\"Corrupted input: expected byte 0 or 1, received \" + b);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Seekable s = Seekable.serializer.deserialize(in, version);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Corrupted input\")) {\n        logger.warn(\"Corrupt Seekable tag byte; dropping message\", e);\n    } else throw e;\n}","preventionTips":["Remember valid Seekable tags are 0 and 1; the message text is stale.","Keep serializers byte-compatible across rolling upgrades.","Close/realign streams after any tag-byte failure."],"tags":["serialization","accord","corrupted-input","seekable"],"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"}