apache/cassandra · error · InvalidRequestException

Unknown field '%s' in value of user defined type %s

Error message

Unknown field '%s' in value of user defined type %s

What it means

A UDT literal in the selection clause names a field that does not exist in the target user type (fieldPosition returns -1). Cassandra validates literal keys against the UserType definition and rejects unknown fields at prepare time.

Source

Thrown at src/java/org/apache/cassandra/cql3/selection/Selectable.java:1170

                                              AbstractType<?> expectedType,
                                              List<ColumnMetadata> defs,
                                              VariableSpecifications boundNames)
        {
            UserType ut = (UserType) expectedType;
            Map<FieldIdentifier, Factory> factories = new LinkedHashMap<>(ut.size());

            for (Pair<Selectable.Raw, Selectable.Raw> raw : raws)
            {
                if (!(raw.left instanceof RawIdentifier))
                    throw invalidRequest("%s is not a valid field identifier of type %s ",
                                         raw.left,
                                         ut.getNameAsString());

                FieldIdentifier fieldName = ((RawIdentifier) raw.left).toFieldIdentifier();
                int fieldPosition = ut.fieldPosition(fieldName);

                if (fieldPosition == -1)
                    throw invalidRequest("Unknown field '%s' in value of user defined type %s",
                                         fieldName,
                                         ut.getNameAsString());

                AbstractType<?> fieldType = ut.fieldType(fieldPosition);
                factories.put(fieldName,
                              raw.right.prepare(cfm).newSelectorFactory(cfm, fieldType, defs, boundNames));
            }

            return UserTypeSelector.newFactory(expectedType, factories);
        }

        @Override
        public AbstractType<?> getExactTypeIfKnown(String keyspace)
        {
            // Let's force the user to specify the type.
            return null;
        }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Run DESCRIBE TYPE <keyspace>.<type> and correct the field name in the literal to match exactly.
  2. Quote the identifier if the field name is case-sensitive or contains special characters: {"Street":'x'}.
  3. Update application code/queries after UDT field renames; check for removed/renamed fields.

Example fix

// before
SELECT (address) {streat:'Main'} FROM t;
// after
SELECT (address) {street:'Main'} FROM t;
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = userType.getFieldNames(); for (String f : literalFields) if (!valid.contains(f)) throw new IllegalArgumentException("unknown field " + f + " for UDT " + userType.getName());

Try / catch

try { session.execute(stmt); } catch (InvalidRequestException e) { if (e.getMessage().contains("Unknown field")) { /* refresh field names from DESCRIBE TYPE */ } else throw e; }

Prevention

When it happens

Trigger: `SELECT (address) {streat:'x'} FROM t` — misspelled field name; field renamed in the type but literals not updated; using a field from a different UDT.

Common situations: UDT schema evolution (fields added/renamed) with stale queries; case-sensitivity issues with unquoted vs quoted identifiers; typos in hand-written literals.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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