apache/cassandra · error · ProtocolException
Unknown kind id in RESULT message
Error message
Unknown kind id %d in RESULT message
What it means
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.
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
Example fix
// before
int kind = buffer.readInt(); // garbage due to truncated frame
// after
if (buffer.readableBytes() < 4)
throw new DecoderException("truncated RESULT frame");
int kind = buffer.readInt(); Defensive patterns
Strategy: try-catch
Validate before calling
if (buffer.readableBytes() < 4)
throw new DecoderException("RESULT frame truncated before kind id"); Type guard
boolean isKnownResultKind(int id) {
return id >= 0x01 && id <= 0x05; // Void..SchemaChange
} Try / catch
try {
ResultMessage msg = ResultMessage.decoder.decode(frame);
} catch (ProtocolException e) {
if (e.getMessage().contains("Unknown kind id")) {
log.warn("malformed RESULT frame; reconnecting", e);
reconnect();
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Missing value CQL_VERSION in STARTUP message
- The page size cannot be 0
- The page size cannot be 0
- There were markers(?) in CQL but bound variables
- A TTL must be greater or equal to 0, but was
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/2b6d057e3d1cdbf6.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/transport/messages/ResultMessage.java:91
for (Kind k : Kind.values())
{
if (ids[k.id] != null)
throw new IllegalStateException("Duplicate kind id");
ids[k.id] = k;
}
}
private Kind(int id, Message.Codec<ResultMessage> subcodec)
{
this.id = id;
this.subcodec = subcodec;
}
public static Kind fromId(int id)
{
Kind k = ids[id];
if (k == null)
throw new ProtocolException(String.format("Unknown kind id %d in RESULT message", id));
return k;
}
}
public final Kind kind;
protected ResultMessage(Kind kind)
{
super(Message.Type.RESULT);
this.kind = kind;
}
public static class Void extends ResultMessage
{
// Even though we have no specific information here, don't make a
// singleton since as each message it has in fact a streamid and connection.
public Void()
{View on GitHub (pinned to 88fd0f6a0e)