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
- Run DESCRIBE TYPE <keyspace>.<type> and correct the field name in the literal to match exactly.
- Quote the identifier if the field name is case-sensitive or contains special characters: {"Street":'x'}.
- 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
- Fetch UDT field names from driver metadata before building literals.
- Re-validate queries after any ALTER TYPE rename/drop.
- Handle identifier case consistently (quote when needed).
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
- Non-frozen UDTs are not allowed inside collections:
- Statement on keyspace %s cannot refer to a user type in keys
- Invalid field deletion operation for non-UDT column %s
- Non-frozen UDTs with nested non-frozen collections are not s
- Cannot drop non-frozen column %s of user type %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/368ab47a3eb0f69b.
Report an issue: GitHub.