{"record":{"id":"76cdb4e39bb6cf9d","repo":"apache/cassandra","slug":"s-of-type-s-has-no-field-s","errorCode":null,"errorMessage":"%s of type %s has no field %s","messagePattern":"(.+?) of type (.+?) has no field (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/selection/Selectable.java","lineNumber":577,"sourceCode":"                BetweenParenthesesOrWithTuple betweenParentheses = (BetweenParenthesesOrWithTuple) selected;\n                expectedUdtType = betweenParentheses.selectables.get(0).getExactTypeIfKnown(table.keyspace);\n            }\n\n            Selector.Factory factory = selected.newSelectorFactory(table, expectedUdtType, defs, boundNames);\n            AbstractType<?> type = factory.getReturnType().unwrap();\n            if (!type.isUDT())\n            {\n                throw new InvalidRequestException(\n                        String.format(\"Invalid field selection: %s of type %s is not a user type\",\n                                selected,\n                                type.asCQL3Type()));\n            }\n\n            UserType ut = (UserType) type;\n            int fieldIndex = ut.fieldPosition(field);\n            if (fieldIndex == -1)\n            {\n                throw new InvalidRequestException(String.format(\"%s of type %s has no field %s\",\n                        selected, type.asCQL3Type(), field));\n            }\n\n            return FieldSelector.newFactory(ut, fieldIndex, factory);\n        }\n\n        public AbstractType<?> getExactTypeIfKnown(String keyspace)\n        {\n            AbstractType<?> selectedType = selected.getExactTypeIfKnown(keyspace);\n            if (selectedType == null || !(selectedType instanceof UserType))\n                return null;\n\n            UserType ut = (UserType) selectedType;\n            int fieldIndex = ut.fieldPosition(field);\n            if (fieldIndex == -1)\n                return null;\n\n            return ut.fieldType(fieldIndex);","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/selection/Selectable.java#L559-L595","documentation":"Field selection resolved the receiver as a UDT, but the requested field name does not exist in the type definition: UserType.fieldPosition returns -1 and the query is rejected, naming the receiver, the UDT type, and the unknown field.","triggerScenarios":"SELECT addr.citty FROM t where the UDT 'addr' has no field named 'citty' (typo, case sensitivity, or UDT altered in a newer schema version).","commonSituations":"UDT fields renamed/dropped by ALTER TYPE after client code was written; schema drift between environments; case-sensitive field names (UDT fields created quoted).","solutions":["Check the field name against DESCRIBE TYPE / system_schema.types","Re-sync client queries with the current UDT definition after ALTER TYPE ... RENAME/ADD","Quote the field identifier exactly if it was created case-sensitively"],"exampleFix":"// before\nSELECT addr.zipcode FROM t; // UDT has 'zip'\n// after\nSELECT addr.zip FROM t;","handlingStrategy":"validation","validationCode":"UserType ut = (UserType) col.getType().unwrap();\nif (ut.fieldPosition(fieldName) < 0) throw new IllegalArgumentException(ut.getNameAsString() + \" has no field \" + fieldName);","typeGuard":"boolean hasField(UserType ut, String f) { return ut.fieldPosition(f) != -1; }","tryCatchPattern":null,"preventionTips":["Validate UDT field names against system_schema.types at startup","Re-run schema validation after ALTER TYPE changes","Be careful with quoted/case-sensitive field identifiers"],"tags":["cql","udt","field-selection"],"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-17T15:17:12.973Z"}