{"record":{"id":"935b7248baeed5c2","repo":"apache/cassandra","slug":"invalid-user-type-literal-for-s-field-s-is-not","errorCode":null,"errorMessage":"Invalid user type literal for %s: field %s is not of type %s","messagePattern":"Invalid user type literal for (.+?): field (.+?) is not of type (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/terms/UserTypes.java","lineNumber":76,"sourceCode":"\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\n    /**\n     * Tests that the map with the specified entries can be assigned to the specified column.\n     *\n     * @param receiver the receiving column\n     * @param entries the map entries\n     */\n    public static <T extends AssignmentTestable> AssignmentTestable.TestResult testUserTypeAssignment(ColumnSpecification receiver,\n                                                                                                      Map<FieldIdentifier, T> entries)\n    {\n        try\n        {\n            validateUserTypeAssignableTo(receiver, entries);\n            return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/terms/UserTypes.java#L58-L94","documentation":"Fired per-field in validateUserTypeAssignableTo: a UDT literal field value is not assignable to the corresponding field type of the UserType (skipping nulls and matching by field position). The message names the column, the field, and the expected field type.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/terms/UserTypes.java:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the literal field value so its type matches the UDT field's declared type","Recreate/alter the UDT or use the correct field value in the literal"],"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"}