{"record":{"id":"05f2ef3ad80b829a","repo":"apache/cassandra","slug":"duplicate-field-name-s-in-type-s-05f2ef","errorCode":null,"errorMessage":"Duplicate field name '%s' in type '%s'","messagePattern":"Duplicate field name '(.+?)' in type '(.+?)'","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java","lineNumber":107,"sourceCode":"    {\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        if (null == keyspace)\n            throw ire(\"Keyspace '%s' doesn't exist\", keyspaceName);\n\n        UserType existingType = keyspace.types.getNullable(bytes(typeName));\n        if (null != existingType)\n        {\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    }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java#L89-L125","documentation":"CreateTypeStatement.apply validation: the same field name appears more than once in the UDT's field list (detected via a HashSet of FieldIdentifier); duplicate field names are not permitted in a user-defined type.","triggerScenarios":"Thrown at src/java/org/apache/cassandra/cql3/statements/schema/CreateTypeStatement.java:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename or remove duplicate fields so each field name in the type is unique."],"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"}