{"record":{"id":"e84d38b91f04baf3","repo":"apache/cassandra","slug":"a-user-type-cannot-contain-non-frozen-udts-e84d38","errorCode":null,"errorMessage":"A user type cannot contain non-frozen UDTs","messagePattern":"A user type cannot contain non-frozen UDTs","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java","lineNumber":115,"sourceCode":"        {\n            if (ifNotExists)\n                return schema;\n\n            throw ire(\"A user type with name '%s' already exists\", typeName);\n        }\n\n        Set<FieldIdentifier> usedNames = new HashSet<>();\n        for (FieldIdentifier name : fieldNames)\n            if (!usedNames.add(name))\n                throw ire(\"Duplicate field name '%s' in type '%s'\", name, typeName);\n\n        for (CQL3Type.Raw type : rawFieldTypes)\n        {\n            if (type.isCounter())\n                throw ire(\"A user type cannot contain counters\");\n\n            if (type.isUDT() && !type.isFrozen())\n                throw ire(\"A user type cannot contain non-frozen UDTs\");\n        }\n\n        List<AbstractType<?>> fieldTypes =\n            rawFieldTypes.stream()\n                         .map(t -> t.prepare(keyspaceName, keyspace.types).getType())\n                         .collect(toList());\n\n        UserType udt = new UserType(keyspaceName, bytes(typeName), fieldNames, fieldTypes, true);\n        return schema.withAddedOrUpdated(keyspace.withSwapped(keyspace.types.with(udt)));\n    }\n\n    SchemaChange schemaChangeEvent(KeyspacesDiff diff)\n    {\n        return new SchemaChange(Change.CREATED, Target.TYPE, keyspaceName, typeName);\n    }\n\n    public void authorize(ClientState client)\n    {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java#L97-L133","documentation":"Validation guard in CreateTypeStatement.apply() fired during CREATE TYPE: a field's type resolves to a user-defined type that is not frozen. Since non-frozen UDTs cannot be nested inside another UDT (their inner fields would not be updateable in place), the statement is rejected with InvalidRequestException before any schema mutation.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Declare the nested UDT field as frozen, e.g. frozen<other_type>, in the CREATE TYPE statement; flatten the nested type into the outer type if freezing is not desired; create the inner type already frozen at its own definition if the schema design permits."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}