{"record":{"id":"2b6d05275fe61699","repo":"apache/cassandra","slug":"unknown-type","errorCode":null,"errorMessage":"Unknown type ","messagePattern":"Unknown type ","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/CQL3Type.java","lineNumber":1024,"sourceCode":"            public CQL3Type prepare(String keyspace, Types udts) throws InvalidRequestException\n            {\n                if (name.hasKeyspace())\n                {\n                    // The provided keyspace is the one of the current statement this is part of. If it's different from the keyspace of\n                    // the UTName, we reject since we want to limit user types to their own keyspace (see #6643)\n                    if (!keyspace.equals(name.getKeyspace()))\n                        throw new InvalidRequestException(String.format(\"Statement on keyspace %s cannot refer to a user type in keyspace %s; \"\n                                                                        + \"user types can only be used in the keyspace they are defined in\",\n                                                                        keyspace, name.getKeyspace()));\n                }\n                else\n                {\n                    name.setKeyspace(keyspace);\n                }\n\n                UserType type = udts.getNullable(name.getUserTypeName());\n                if (type == null)\n                    throw new InvalidRequestException(\"Unknown type \" + name);\n\n                if (frozen)\n                    type = type.freeze();\n                return new UserDefined(name.toString(), type);\n            }\n\n            public boolean referencesUserType(String name)\n            {\n                return this.name.getStringTypeName().equals(name);\n            }\n\n            public boolean supportsFreezing()\n            {\n                return true;\n            }\n\n            public boolean isUDT()\n            {","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/CQL3Type.java#L1006-L1042","documentation":"InvalidRequestException from the RawType prepare path: the type name in a DDL/statement does not resolve to a known type in the statement's keyspace (native types or a declared UDT). The prepare step looks the name up in the Types registry of the keyspace and throws this when the lookup fails; a related guard enforces that user types are only referenced from their own keyspace (#6643).","triggerScenarios":"Referencing a type name in CREATE TABLE / ALTER TABLE that was never created via CREATE TYPE in the current (or explicitly named) keyspace, or with a typo/case-mismatch, or in the wrong keyspace.","commonSituations":"Forgetting to run CREATE TYPE before the table DDL; running migrations against a fresh environment; connecting to a cluster where the type lives in another keyspace.","solutions":["Create the type first: `CREATE TYPE <keyspace>.<name> (...);` then re-run the statement","Check for typos and case sensitivity (unquoted identifiers are lowercased)","Verify you are in/qualifying the correct keyspace (DESCRIBE TYPES / system_schema.types)","If the type was dropped, restore it from schema backups before dependent DDL"],"exampleFix":"// before\nCREATE TABLE t (id uuid PRIMARY KEY, a mytype); -- mytype missing\n// after\nCREATE TYPE mytype (field text);\nCREATE TABLE t (id uuid PRIMARY KEY, a frozen<mytype>);","handlingStrategy":"try-catch","validationCode":"ResultSet rs = session.execute(\n    \"SELECT keyspace_name, type_name FROM system_schema.types WHERE keyspace_name = ? AND type_name = ?\",\n    ks, typeName.toLowerCase());\nboolean typeExists = rs.iterator().hasNext();","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidQueryException e) { if (e.getMessage().startsWith(\"Unknown type\")) { /* run CREATE TYPE first, then retry */ } else throw e; }","preventionTips":["Run CREATE TYPE statements before any DDL/DML referencing the type in every environment","Check system_schema.types for existence in migration tooling","Watch identifier case: unquoted names are lowercased"],"tags":["cql","udt","not-found","keyspace"],"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"}