apache/cassandra · error · InvalidRequestException

UDT column %s does not have a field named %s

Error message

UDT column %s does not have a field named %s

What it means

Cassandra throws this during preparation when a UDT field update names a field that does not exist in the UDT type definition. UserType.fieldPosition(field) returns -1 and the statement is rejected before execution.

Source

Thrown at src/java/org/apache/cassandra/cql3/Operation.java:303

        private final FieldIdentifier field;
        private final Term.Raw value;

        public SetField(FieldIdentifier field, Term.Raw value)
        {
            this.field = field;
            this.value = value;
        }

        public Operation prepare(TableMetadata metadata, ColumnMetadata receiver, boolean canReadExistingState) throws InvalidRequestException
        {
            if (!receiver.type.isUDT())
                throw new InvalidRequestException(String.format("Invalid operation (%s) for non-UDT column %s", toString(receiver), receiver.name));
            else if (!receiver.type.isMultiCell())
                throw new InvalidRequestException(String.format("Invalid operation (%s) for frozen UDT column %s", toString(receiver), receiver.name));

            int fieldPosition = ((UserType) receiver.type).fieldPosition(field);
            if (fieldPosition == -1)
                throw new InvalidRequestException(String.format("UDT column %s does not have a field named %s", receiver.name, field));

            Term val = value.prepare(metadata.keyspace, UserTypes.fieldSpecOf(receiver, fieldPosition));
            return new UserTypes.SetterByField(receiver, field, val);
        }

        protected String toString(ColumnSpecification column)
        {
            return String.format("%s.%s = %s", column.name, field, value);
        }

        public boolean isCompatibleWith(RawUpdate other)
        {
            if (other instanceof SetField)
                return !((SetField) other).field.equals(field);
            else
                return !(other instanceof SetValue);
        }
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Check the UDT definition (DESCRIBE TYPE / system_schema.types) and use an existing field name
  2. Fix the field-name spelling/case in the query
  3. If the field is genuinely needed, recreate the UDT with the additional field and migrate data
  4. Regenerate client models/ORM mappings from the current schema

Example fix

// before (address_udt has 'zipCode', not 'zip')
UPDATE users SET address.zip = '10001' WHERE id = 1;
// after
UPDATE users SET address.zipCode = '10001' WHERE id = 1;
Defensive patterns

Strategy: validation

Validate before calling

UserType ut = (UserType) tm.getColumn(col).getType();
if (ut.fieldPosition(fieldName) == -1)
    throw new IllegalArgumentException("UDT " + ut.getNameAsString() + " has no field " + fieldName);

Type guard

boolean udtHasField(UserType ut, String f) { return ut.fieldPosition(f) != -1; }

Try / catch

try { session.execute(update); } catch (InvalidRequestException e) { if (e.getMessage().contains("does not have a field named")) refreshUdtModelAndRetry(); else throw e; }

Prevention

When it happens

Trigger: 'UPDATE t SET myudt.wrongfield = v WHERE ...' where 'wrongfield' is not one of the fields defined in the CREATE TYPE ... definition (typo, case mismatch, renamed field).

Common situations: UDT field renamed or removed via type re-creation while client code still references old names; typos; clients built against a different keyspace's same-named UDT.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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