{"record":{"id":"6f71bfb0e4aa16d0","repo":"apache/cassandra","slug":"non-frozen-udts-are-not-allowed-inside-collections","errorCode":null,"errorMessage":"Non-frozen UDTs are not allowed inside collections: ","messagePattern":"Non-frozen UDTs are not allowed inside collections: ","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/CQL3Type.java","lineNumber":899,"sourceCode":"                switch (kind)\n                {\n                    case LIST:\n                        return new Collection(ListType.getInstance(valueType, !frozen));\n                    case SET:\n                        return new Collection(SetType.getInstance(valueType, !frozen));\n                    case MAP:\n                        assert keys != null : \"Got null keys type for a collection\";\n                        return new Collection(MapType.getInstance(keys.prepare(keyspace, udts).getType(), valueType, !frozen));\n                }\n                throw new AssertionError();\n            }\n\n            private void throwNestedNonFrozenError(Raw innerType)\n            {\n                if (innerType instanceof RawCollection)\n                    throw new InvalidRequestException(\"Non-frozen collections are not allowed inside collections: \" + this);\n                else if (innerType.isUDT())\n                    throw new InvalidRequestException(\"Non-frozen UDTs are not allowed inside collections: \" + this);\n            }\n\n            public boolean referencesUserType(String name)\n            {\n                return (keys != null && keys.referencesUserType(name)) || values.referencesUserType(name);\n            }\n\n            @Override\n            public String toString()\n            {\n                String start = frozen? \"frozen<\" : \"\";\n                String end = frozen ? \">\" : \"\";\n                switch (kind)\n                {\n                    case LIST: return start + \"list<\" + values + '>' + end;\n                    case SET:  return start + \"set<\" + values + '>' + end;\n                    case MAP:  return start + \"map<\" + keys + \", \" + values + '>' + end;\n                }","sourceCodeStart":881,"sourceCodeEnd":917,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/CQL3Type.java#L881-L917","documentation":"InvalidRequestException (via throwNestedNonFrozenError) raised while preparing a collection type whose elements include a non-frozen user-defined type. Only frozen UDTs may appear inside collections; the check triggers when the value type supports freezing but was left unfrozen.","triggerScenarios":"Declaring e.g. `list<address>` or `map<text, address>` where `address` is a UDT declared without frozen<> in CREATE TABLE / ALTER TABLE.","commonSituations":"Common when first using UDTs in Cassandra — developers forget frozen is mandatory for UDTs inside collections.","solutions":["Wrap the UDT in frozen<>: `list<frozen<address>>`","Freeze the UDT at definition time (`CREATE TYPE ... ` then use frozen<address> everywhere it is nested)","Restructure into a separate table if per-field updates on nested UDTs are needed"],"exampleFix":"// before\nCREATE TABLE t (id uuid PRIMARY KEY, addresses list<address>);\n// after\nCREATE TABLE t (id uuid PRIMARY KEY, addresses list<frozen<address>>);","handlingStrategy":"validation","validationCode":"boolean hasNonFrozenUdtInCollection(String typeDecl, java.util.Set<String> udtNames) {\n    String s = typeDecl.toLowerCase();\n    return udtNames.stream().anyMatch(u -> s.matches(\".*<(?!frozen\\\\s*<)\" + u + \"[>,].*\"));\n}","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidQueryException e) { if (e.getMessage().startsWith(\"Non-frozen UDTs are not allowed inside collections\")) { /* use frozen<udt> inside collections */ } else throw e; }","preventionTips":["UDTs inside collections must always be frozen<>","Create UDTs before dependent table DDL and keep definitions keyspace-local","Consider separate tables if you need to update UDT fields in place"],"tags":["cql","schema","udt","frozen"],"backgroundTag":"schema-validation-failed","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"}