{"record":{"id":"e7f9a710fe6772a3","repo":"apache/cassandra","slug":"invalid-type-id-d","errorCode":null,"errorMessage":"Invalid type id: %d","messagePattern":"Invalid type id: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/streaming/messages/StreamMessage.java","lineNumber":90,"sourceCode":"        STREAM_INIT    (10, 5, StreamInitMessage.serializer   );\n\n        private static final Map<Integer, Type> idToTypeMap;\n\n        static\n        {\n            idToTypeMap = new HashMap<>();\n            for (Type t : values())\n            {\n                if (idToTypeMap.put(t.id, t) != null)\n                    throw new RuntimeException(\"Two StreamMessage Types map to the same id: \" + t.id);\n            }\n        }\n\n        public static Type lookupById(int id)\n        {\n            Type t = idToTypeMap.get(id);\n            if (t == null)\n                throw new IllegalArgumentException(\"Invalid type id: \" + id);\n\n            return t;\n        }\n\n        public final int id;\n        public final int priority;\n\n        public final Serializer<StreamMessage> inSerializer;\n        public final Serializer<StreamMessage> outSerializer;\n\n        Type(int id, int priority, Serializer serializer)\n        {\n            this(id, priority, serializer, serializer);\n        }\n\n        @SuppressWarnings(\"unchecked\")\n        Type(int id, int priority, Serializer inSerializer, Serializer outSerializer)\n        {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/streaming/messages/StreamMessage.java#L72-L108","documentation":"StreamMessage.Type assigns an integer id to each streaming message type; lookupById resolves ids received off the wire back to a Type. IllegalArgumentException means the peer sent a message-type id this node's idToTypeMap does not know — almost always a protocol/version mismatch between nodes or corrupted stream data.","triggerScenarios":"deserialize() reads a type id from the wire and calls Type.lookupById(id); the id is not registered — nodes running different Cassandra versions where one knows message types the other does not, or byte corruption/misframing of the stream protocol.","commonSituations":"Rolling upgrades/downgrades across versions with streaming protocol changes; mixing nodes from incompatible branches in a test cluster; deserializing garbage after a framing offset bug (e.g. following an earlier malformed message).","solutions":["Bring all cluster nodes to the same Cassandra version (complete rolling upgrade) and retry streaming","Verify messagingVersion negotiation between the two nodes; check cassandra versions with nodetool version on both ends","If corruption is suspected, check network health and restart the stream session; inspect the raw id in the log against known Type ids","If seen in tests after adding a new StreamMessage.Type, ensure the new type is registered in the static idToTypeMap on both sides"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"int id = input.readInt();\nif (StreamMessage.Type.idToTypeMap.get(id) == null) throw new IOException(\"peer sent unknown stream type \" + id + \"; version mismatch?\");","typeGuard":null,"tryCatchPattern":"try { Type t = StreamMessage.Type.lookupById(id); }\ncatch (IllegalArgumentException e) {\n    throw new IOException(\"stream protocol mismatch (id=\" + id + \"); check node versions\", e);\n}","preventionTips":["Keep all nodes on the same Cassandra version during streaming operations","Complete rolling upgrades before running repairs/rebuilds","Register any custom/new StreamMessage.Type ids on both sender and receiver","Treat unexpected type ids as a transport/framing problem: restart the session"],"tags":["streaming","protocol","version-skew"],"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"}