{"record":{"id":"1bbfb9cc1e8d5449","repo":"apache/cassandra","slug":"invalid-user-type-literal-for-s-of-type-s","errorCode":null,"errorMessage":"Invalid user type literal for %s of type %s","messagePattern":"Invalid user type literal for (.+?) of type (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/terms/UserTypes.java","lineNumber":63,"sourceCode":" */\npublic final class UserTypes\n{\n    private UserTypes() {}\n\n    public static ColumnSpecification fieldSpecOf(ColumnSpecification column, int field)\n    {\n        UserType ut = (UserType)column.type.unwrap();\n        return new ColumnSpecification(column.ksName,\n                                       column.cfName,\n                                       new ColumnIdentifier(column.name + \".\" + ut.fieldName(field), true),\n                                       ut.fieldType(field));\n    }\n\n    public static <T extends AssignmentTestable> void validateUserTypeAssignableTo(ColumnSpecification receiver,\n                                                                                   Map<FieldIdentifier, T> entries)\n    {\n        if (!receiver.type.isUDT())\n            throw new InvalidRequestException(String.format(\"Invalid user type literal for %s of type %s\", receiver, receiver.type.asCQL3Type()));\n\n        UserType ut = (UserType) receiver.type;\n        for (int i = 0; i < ut.size(); i++)\n        {\n            FieldIdentifier field = ut.fieldName(i);\n            T value = entries.get(field);\n            if (value == null)\n                continue;\n\n            ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);\n            if (!value.testAssignment(receiver.ksName, fieldSpec).isAssignable())\n            {\n                throw new InvalidRequestException(String.format(\"Invalid user type literal for %s: field %s is not of type %s\",\n                        receiver, field, fieldSpec.type.asCQL3Type()));\n            }\n        }\n    }\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/terms/UserTypes.java#L45-L81","documentation":"Generic guard in UserTypes.validateUserTypeAssignableTo: the receiver column's type is not a UDT, so a user-type literal cannot be assigned to it. The message names the column and its actual CQL3 type; the at-fault input is the non-UDT target column of the UDT literal.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/terms/UserTypes.java:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a UDT literal only against a column whose type is that user-defined type","Verify the column type and rewrite the literal as a valid UDL with matching fields"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}