{"record":{"id":"efeaa5d5404be367","repo":"apache/cassandra","slug":"invalid-reference-type-s-s-for-s-of-type-s","errorCode":null,"errorMessage":"Invalid reference type %s (%s) for \"%s\" of type %s","messagePattern":"Invalid reference type (.+?) \\((.+?)\\) for \"(.+?)\" of type (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/transactions/RowDataReference.java","lineNumber":366,"sourceCode":"        {\n            return prepare(keyspace, receiver, tupleName, column, elementPath, fieldPath);\n        }\n\n        public RowDataReference prepareAsReceiver()\n        {\n            checkResolved();\n            return new RowDataReference(tuple.toString(), tupleName, column, table, elementPath, fieldPath);\n        }\n\n        private RowDataReference prepare(String keyspace,\n                                         ColumnSpecification receiver,\n                                         int txnDataName,\n                                         ColumnMetadata column,\n                                         Term elementPath,\n                                         CellPath fieldPath)\n        {\n            if (!testAssignment(keyspace, receiver).isAssignable())\n                throw new InvalidRequestException(String.format(\"Invalid reference type %s (%s) for \\\"%s\\\" of type %s\",\n                                                                column.type, column.name, receiver.name, receiver.type.asCQL3Type()));\n\n            return new RowDataReference(tuple.toString(), txnDataName, column, table, elementPath, fieldPath);\n        }\n\n        @Override\n        public String getText()\n        {\n            StringBuilder text = new StringBuilder(tuple.toString());\n\n            if (selected != null)\n                text.append('.').append(selected);\n\n            if (fieldOrElement != null)\n            {\n                if (fieldOrElement instanceof Term.Raw)\n                {\n                    Term.Raw element = (Term.Raw) fieldOrElement;","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/transactions/RowDataReference.java#L348-L384","documentation":"Thrown when preparing a RowDataReference in a transaction: the referenced column's type is not assignable to the receiver the data reference was resolved against. testAssignment fails and the exception reports the column type, column name, receiver name, and receiver type.","triggerScenarios":"A transaction data reference (e.g. `data.ref` used in a condition or update) whose column type does not match what the consuming receiver expects, e.g. referencing an int column where a text value is required in the transaction statement.","commonSituations":"Type drift between the referenced column and the transaction's target/condition after a schema change; building transaction references programmatically with mismatched types.","solutions":["Align the referenced column type with the receiver (cast or use a column of the correct type).","Check the transaction statement's conditions and targets against the referenced column types.","Re-validate prepared transactions after schema alterations."],"exampleFix":"// before\nSELECT balance FROM data WHERE ...; // used where text expected\nIF updated.text_col = data.balance ... // balance is int, text_col is text\n// after\nIF updated.num_col = data.balance ... // matching int types","handlingStrategy":"validation","validationCode":"if (!referencedColumn.type.testAssignment(keyspace, receiver).isAssignable())\n    throw new IllegalArgumentException(\"Reference \" + referencedColumn.name + \" not assignable to \" + receiver.name);","typeGuard":null,"tryCatchPattern":"try { session.execute(txnStmt); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"Invalid reference type\")) alignReferenceTypes(); else throw e; }","preventionTips":["Match referenced column types to receivers in transaction conditions","Re-validate transactions after schema changes","Avoid implicit cross-type references"],"tags":["cql","transactions","type-mismatch"],"backgroundTag":"type-mismatch","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"}