{"record":{"id":"4fa19b91b99a74de","repo":"apache/cassandra","slug":"unrecognized-kind-kind","errorCode":null,"errorMessage":"Unrecognized kind {kind}","messagePattern":"Unrecognized kind (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/txn/TxnDataValue.java","lineNumber":64,"sourceCode":"\n        int id;\n\n        Kind(int id)\n        {\n            this.id = id;\n        }\n\n        @SuppressWarnings(\"unchecked\")\n        public <T extends TxnDataValue> IVersionedSerializer<T> serializer()\n        {\n            switch (this)\n            {\n                case key:\n                    return (IVersionedSerializer<T>) TxnDataKeyValue.serializer;\n                case range:\n                    return (IVersionedSerializer<T>) TxnDataRangeValue.serializer;\n                default:\n                    throw new IllegalStateException(\"Unrecognized kind \" + this);\n            }\n        }\n    }\n\n    TxnDataValue.Kind kind();\n\n    TxnDataValue merge(TxnDataValue other);\n    @Nullable TxnDataValue without(Ranges ranges);\n    long maxTimestamp();\n\n    long estimatedSizeOnHeap();\n\n    IVersionedSerializer<TxnDataValue> serializer = new IVersionedSerializer<>()\n    {\n        @SuppressWarnings(\"unchecked\")\n        @Override\n        public void serialize(TxnDataValue txnDataValue, DataOutputPlus out, Version version) throws IOException\n        {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/txn/TxnDataValue.java#L46-L82","documentation":"Returns the serializer for a TxnDataValue.Kind: key → TxnDataKeyValue.serializer, range → TxnDataRangeValue.serializer. Unlike sibling switches that throw IllegalArgumentException, this throws IllegalStateException because the default case is considered unreachable for a well-formed two-value enum — hitting it signals internal state corruption or a build mismatch.","triggerScenarios":"Calling Kind.serializer() with a Kind value that is neither 'key' nor 'range' — only possible via a mismatched enum (different class versions on the classpath) or corrupted in-memory state.","commonSituations":"Stale JARs / mixed Cassandra versions in the classpath; shaded or duplicate TxnDataValue classes; memory corruption or bytecode weaving tools altering the enum.","solutions":["Ensure a single consistent Cassandra build is deployed (check for duplicate/stale JARs on the classpath).","Rebuild and redeploy if the enum was modified locally.","If adding a new Kind, extend the switch with the corresponding serializer before using it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"TxnDataValue.Kind k = ...;\nif (k != TxnDataValue.Kind.key && k != TxnDataValue.Kind.range)\n    throw new IllegalStateException(\"Unexpected TxnDataValue kind: \" + k);","typeGuard":"static boolean isKnownKind(TxnDataValue.Kind k) {\n    return k == TxnDataValue.Kind.key || k == TxnDataValue.Kind.range;\n}","tryCatchPattern":"try {\n    IVersionedSerializer<T> s = kind.serializer();\n} catch (IllegalStateException e) {\n    logger.error(\"Corrupted/unknown TxnDataValue kind - classpath or build mismatch\", e);\n    throw new IllegalStateException(\"Aborting: serializer unavailable\", e);\n}","preventionTips":["Ensure only one Cassandra JAR version on the classpath","Rebuild after modifying enum definitions","Extend the switch whenever adding a new Kind","Run smoke tests after dependency or shading changes"],"tags":["accord","serialization","transactions"],"backgroundTag":"internal-invariant-violation","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"}