{"record":{"id":"29cdd54fc86f39ec","repo":"apache/cassandra","slug":"unhandled-domain-domain-29cdd5","errorCode":null,"errorMessage":"Unhandled domain {domain}","messagePattern":"Unhandled domain (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/accord/txn/TxnRead.java","lineNumber":96,"sourceCode":"import static org.apache.cassandra.utils.NullableSerializer.serializeNullable;\nimport static org.apache.cassandra.utils.NullableSerializer.serializedNullableSize;\n\npublic class TxnRead extends AbstractKeySorted<TxnNamedRead> implements Read\n{\n    private static final TxnRead EMPTY_KEY = new TxnRead(TableMetadatas.none(), Domain.Key);\n    private static final TxnRead EMPTY_RANGE = new TxnRead(TableMetadatas.none(), Domain.Range);\n    private static final long EMPTY_SIZE = ObjectSizes.measure(EMPTY_KEY);\n    private static final Comparator<TxnNamedRead> TXN_NAMED_READ_KEY_COMPARATOR = Comparator.comparing(a -> ((PartitionKey) a.key()));\n    private static final byte TYPE_EMPTY_KEY = 0;\n    private static final byte TYPE_EMPTY_RANGE = 1;\n    private static final byte TYPE_NOT_EMPTY = 2;\n\n    public static TxnRead empty(Domain domain)\n    {\n        switch (domain)\n        {\n            default:\n                throw new IllegalStateException(\"Unhandled domain \" + domain);\n            case Key:\n                return EMPTY_KEY;\n            case Range:\n                return EMPTY_RANGE;\n        }\n    }\n\n    final TableMetadatas tables;\n    // Cassandra's consistency level used by Accord to safely read data written outside of Accord\n    @Nullable\n    private final ConsistencyLevel cassandraConsistencyLevel;\n\n    // Specifies the domain in case the TxnRead is empty and it can't be inferred\n    private final Domain domain;\n\n    private TxnRead(TableMetadatas tables, Domain domain)\n    {\n        super(new TxnNamedRead[0], domain);","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/accord/txn/TxnRead.java#L78-L114","documentation":"TxnRead.empty() returns the singleton empty read for the given Domain. The switch handles Key and Range and places the throw in the default branch, so any other/unrecognized Domain value throws IllegalStateException. It is an internal exhaustiveness guard.","triggerScenarios":"Calling TxnRead.empty(domain) with a Domain other than Key or Range — e.g. from createTxnRead when the txn's seekables domain is a newly added or corrupted value.","commonSituations":"Adding a new Domain enum constant without updating TxnRead; deserialization of a transaction from a node running different code; logic errors in createTxnRead deriving the domain.","solutions":["Add a case for the new Domain constant returning an appropriate empty TxnRead","Ensure createTxnRead only calls empty() with Key or Range domains","Check for version skew across the cluster"],"exampleFix":"// before\ndefault:\n    throw new IllegalStateException(\"Unhandled domain \" + domain);\n// after\ncase Range:\n    return EMPTY_RANGE;\ndefault:\n    throw new IllegalStateException(\"Unhandled domain \" + domain);","handlingStrategy":"validation","validationCode":"if (domain != Domain.Key && domain != Domain.Range)\n    throw new IllegalArgumentException(\"TxnRead.empty only supports Key or Range, got \" + domain);","typeGuard":"static boolean isEmptySupported(Domain domain) {\n    return domain == Domain.Key || domain == Domain.Range;\n}","tryCatchPattern":"try { TxnRead r = TxnRead.empty(domain); }\ncatch (IllegalStateException e) { /* unknown domain — inspect createTxnRead inputs */ }","preventionTips":["Only derive the domain from the txn's seekables, never from unvalidated input","Cover all Domain values in unit tests for TxnRead factories"],"tags":["accord","serialization","domain-dispatch"],"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"}