{"record":{"id":"ceb267e82119f27a","repo":"apache/cassandra","slug":"name-is-not-a-field-defined-in-this-udt","errorCode":null,"errorMessage":"<name> is not a field defined in this UDT","messagePattern":"<name> is not a field defined in this UDT","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/UDTValue.java","lineNumber":57,"sourceCode":"\n    @Override\n    protected String getName(int i)\n    {\n        return definition.byIdx[i].getName();\n    }\n\n    @Override\n    protected CodecRegistry getCodecRegistry()\n    {\n        return definition.getCodecRegistry();\n    }\n\n    @Override\n    protected int[] getAllIndexesOf(String name)\n    {\n        int[] indexes = definition.byName.get(Metadata.handleId(name));\n        if (indexes == null)\n            throw new IllegalArgumentException(name + \" is not a field defined in this UDT\");\n        return indexes;\n    }\n\n    /**\n     * The UDT this is a value of.\n     *\n     * @return the UDT this is a value of.\n     */\n    public UserType getType()\n    {\n        return definition;\n    }\n\n    @Override\n    public boolean equals(Object o)\n    {\n        if (!(o instanceof UDTValue)) return false;\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/UDTValue.java#L39-L75","documentation":"UDTValue.get* methods resolve a field by name through the UDT definition's byName map. If the provided name does not match any field in the UserDefinedType definition, this IllegalArgumentException is thrown. It is a lookup failure against the UDT schema known to the driver, not a data problem.","triggerScenarios":"udtValue.getString(\"email\") where the UDT defines 'email_address'; calling with a name whose case/identifier form differs after Metadata.handleId normalization; stale UDT definition after an ALTER TYPE ADD on the server.","commonSituations":"Schema changed on the cluster (field added/renamed) but the driver's cluster metadata was prepared earlier; case mismatch — CQL identifiers are case-insensitive unless quoted; copy-pasted field name from a different UDT.","solutions":["Print the actual fields with udtType.getFieldNames() and use an exact name.","Refresh cluster metadata (cluster.refreshSchemaMetadata()) so the driver's UDT definition matches the server after DDL changes.","Use the CQL-declared casing; quote names in CQL only if they were defined quoted, and pass the same string here.","Rebuild the session/connection so the type definition is re-fetched."],"exampleFix":"// before\nString v = udt.getString(\"email\"); // field is 'email_address'\n// after\nString v = udt.getString(\"email_address\");","handlingStrategy":"validation","validationCode":"if (udtType.getFieldNames().stream().noneMatch(n -> n.asInternal().equalsIgnoreCase(name))) throw new IllegalArgumentException(\"unknown UDT field: \" + name);","typeGuard":null,"tryCatchPattern":"try { return udt.getString(name); } catch (IllegalArgumentException e) { if (e.getMessage().endsWith(\"is not a field defined in this UDT\")) throw new SchemaMismatchException(e); throw e; }","preventionTips":["Compare against definition.getFieldNames() before access","Refresh schema metadata after ALTER TYPE on the server","Standardize identifier casing; prefer all-lowercase unquoted names"],"tags":["udt","schema","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-17T15:17:12.973Z"}