{"record":{"id":"2b6d057e3d1cdbf6","repo":"apache/cassandra","slug":"unknown-kind-id-d-in-result-message","errorCode":null,"errorMessage":"Unknown kind id %d in RESULT message","messagePattern":"Unknown kind id (.+?) in RESULT message","errorType":"exception","errorClass":"ProtocolException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/messages/ResultMessage.java","lineNumber":91,"sourceCode":"            for (Kind k : Kind.values())\n            {\n                if (ids[k.id] != null)\n                    throw new IllegalStateException(\"Duplicate kind id\");\n                ids[k.id] = k;\n            }\n        }\n\n        private Kind(int id, Message.Codec<ResultMessage> subcodec)\n        {\n            this.id = id;\n            this.subcodec = subcodec;\n        }\n\n        public static Kind fromId(int id)\n        {\n            Kind k = ids[id];\n            if (k == null)\n                throw new ProtocolException(String.format(\"Unknown kind id %d in RESULT message\", id));\n            return k;\n        }\n    }\n\n    public final Kind kind;\n\n    protected ResultMessage(Kind kind)\n    {\n        super(Message.Type.RESULT);\n        this.kind = kind;\n    }\n\n    public static class Void extends ResultMessage\n    {\n        // Even though we have no specific information here, don't make a\n        // singleton since as each message it has in fact a streamid and connection.\n        public Void()\n        {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/messages/ResultMessage.java#L73-L109","documentation":"Every RESULT message body starts with a kind id (Rows 0x02, SetKeyspace 0x03, Prepared 0x04, SchemaChange 0x05, Void 0x01). Kind.fromId throws a ProtocolException when the id does not map to a known kind — meaning the server produced, or the client decoded, a result payload with an unrecognized kind byte.","triggerScenarios":"Decoding a RESULT frame whose first int is not one of the registered kind ids — a corrupt/truncated frame, a client and server with mismatched protocol expectations, or a hand-rolled client crafting an invalid kind id.","commonSituations":"Buggy third-party drivers or proxies generating malformed result frames; version skew between a custom parser and the server protocol; fuzzers/protocol conformance tests sending arbitrary ids.","solutions":["Verify the client driver version matches the server protocol version and upgrade it","Inspect the raw frame (hex dump) to confirm the message body wasn't truncated or corrupted in transit","Check for intermediaries (proxies, LBs) that rewrite/mangle frames","If writing a custom codec, only emit ids from the protocol spec's RESULT kind table"],"exampleFix":"// before\nint kind = buffer.readInt(); // garbage due to truncated frame\n// after\nif (buffer.readableBytes() < 4)\n    throw new DecoderException(\"truncated RESULT frame\");\nint kind = buffer.readInt();","handlingStrategy":"try-catch","validationCode":"if (buffer.readableBytes() < 4)\n    throw new DecoderException(\"RESULT frame truncated before kind id\");","typeGuard":"boolean isKnownResultKind(int id) {\n    return id >= 0x01 && id <= 0x05; // Void..SchemaChange\n}","tryCatchPattern":"try {\n    ResultMessage msg = ResultMessage.decoder.decode(frame);\n} catch (ProtocolException e) {\n    if (e.getMessage().contains(\"Unknown kind id\")) {\n        log.warn(\"malformed RESULT frame; reconnecting\", e);\n        reconnect();\n    } else throw e;\n}","preventionTips":["Keep driver and server protocol versions aligned","Avoid custom frame-mangling proxies/middleware","Frame-check lengths before decoding message bodies","Fuzz-test custom codecs against known RESULT kind ids"],"tags":["cql","protocol","result","decoding"],"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-17T15:17:12.973Z"}