apache/cassandra · error · InvalidRequestException

Invalid user type literal for

Error message

Invalid user type literal for %s of type %s

What it means

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.

Solutions

  1. Use a UDT literal only against a column whose type is that user-defined type
  2. Verify the column type and rewrite the literal as a valid UDL with matching fields
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/java/org/apache/cassandra/cql3/terms/UserTypes.java:63 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/1bbfb9cc1e8d5449. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/terms/UserTypes.java:63

 */
public final class UserTypes
{
    private UserTypes() {}

    public static ColumnSpecification fieldSpecOf(ColumnSpecification column, int field)
    {
        UserType ut = (UserType)column.type.unwrap();
        return new ColumnSpecification(column.ksName,
                                       column.cfName,
                                       new ColumnIdentifier(column.name + "." + ut.fieldName(field), true),
                                       ut.fieldType(field));
    }

    public static <T extends AssignmentTestable> void validateUserTypeAssignableTo(ColumnSpecification receiver,
                                                                                   Map<FieldIdentifier, T> entries)
    {
        if (!receiver.type.isUDT())
            throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver, receiver.type.asCQL3Type()));

        UserType ut = (UserType) receiver.type;
        for (int i = 0; i < ut.size(); i++)
        {
            FieldIdentifier field = ut.fieldName(i);
            T value = entries.get(field);
            if (value == null)
                continue;

            ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);
            if (!value.testAssignment(receiver.ksName, fieldSpec).isAssignable())
            {
                throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s",
                        receiver, field, fieldSpec.type.asCQL3Type()));
            }
        }
    }

View on GitHub (pinned to 88fd0f6a0e)