{"record":{"id":"3a47483a5c283206","repo":"apache/cassandra","slug":"udt-column-s-does-not-have-a-field-named-s","errorCode":null,"errorMessage":"UDT column %s does not have a field named %s","messagePattern":"UDT column (.+?) does not have a field named (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Operation.java","lineNumber":303,"sourceCode":"        private final FieldIdentifier field;\n        private final Term.Raw value;\n\n        public SetField(FieldIdentifier field, Term.Raw value)\n        {\n            this.field = field;\n            this.value = value;\n        }\n\n        public Operation prepare(TableMetadata metadata, ColumnMetadata receiver, boolean canReadExistingState) throws InvalidRequestException\n        {\n            if (!receiver.type.isUDT())\n                throw new InvalidRequestException(String.format(\"Invalid operation (%s) for non-UDT column %s\", toString(receiver), receiver.name));\n            else if (!receiver.type.isMultiCell())\n                throw new InvalidRequestException(String.format(\"Invalid operation (%s) for frozen UDT column %s\", toString(receiver), receiver.name));\n\n            int fieldPosition = ((UserType) receiver.type).fieldPosition(field);\n            if (fieldPosition == -1)\n                throw new InvalidRequestException(String.format(\"UDT column %s does not have a field named %s\", receiver.name, field));\n\n            Term val = value.prepare(metadata.keyspace, UserTypes.fieldSpecOf(receiver, fieldPosition));\n            return new UserTypes.SetterByField(receiver, field, val);\n        }\n\n        protected String toString(ColumnSpecification column)\n        {\n            return String.format(\"%s.%s = %s\", column.name, field, value);\n        }\n\n        public boolean isCompatibleWith(RawUpdate other)\n        {\n            if (other instanceof SetField)\n                return !((SetField) other).field.equals(field);\n            else\n                return !(other instanceof SetValue);\n        }\n    }","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Operation.java#L285-L321","documentation":"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.","triggerScenarios":"'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).","commonSituations":"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.","solutions":["Check the UDT definition (DESCRIBE TYPE / system_schema.types) and use an existing field name","Fix the field-name spelling/case in the query","If the field is genuinely needed, recreate the UDT with the additional field and migrate data","Regenerate client models/ORM mappings from the current schema"],"exampleFix":"// before (address_udt has 'zipCode', not 'zip')\nUPDATE users SET address.zip = '10001' WHERE id = 1;\n// after\nUPDATE users SET address.zipCode = '10001' WHERE id = 1;","handlingStrategy":"validation","validationCode":"UserType ut = (UserType) tm.getColumn(col).getType();\nif (ut.fieldPosition(fieldName) == -1)\n    throw new IllegalArgumentException(\"UDT \" + ut.getNameAsString() + \" has no field \" + fieldName);","typeGuard":"boolean udtHasField(UserType ut, String f) { return ut.fieldPosition(f) != -1; }","tryCatchPattern":"try { session.execute(update); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"does not have a field named\")) refreshUdtModelAndRetry(); else throw e; }","preventionTips":["Load UDT field names from system_schema.types at startup instead of hardcoding","Regenerate client models when UDT definitions change","Validate field names in unit tests against the live keyspace"],"tags":["cql","cassandra","udt","field-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}