{"record":{"id":"63c82997da916183","repo":"apache/cassandra","slug":"core-cluster-metadata-objects-should-be-addressed","errorCode":null,"errorMessage":"Core cluster metadata objects should be addressed directly, not using the associated MetadataKey","messagePattern":"Core cluster metadata objects should be addressed directly, not using the associated MetadataKey","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tcm/ClusterMetadata.java","lineNumber":936,"sourceCode":"                consensusMigrationState = new ConsensusMigrationState(Epoch.EMPTY, tableMigrationStatesBuilder.build());\n            }\n            else\n            {\n                consensusMigrationState = new ConsensusMigrationState(Epoch.EMPTY, newTableMigrationStates);\n            }\n            return this;\n        }\n\n        public Transformer with(ConsensusMigrationState consensusMigrationState)\n        {\n            this.consensusMigrationState = consensusMigrationState;\n            return this;\n        }\n\n        public Transformer with(ExtensionKey<?, ?> key, ExtensionValue<?> obj)\n        {\n            if (MetadataKeys.CORE_METADATA.containsKey(key))\n                throw new IllegalArgumentException(\"Core cluster metadata objects should be addressed directly, \" +\n                                                   \"not using the associated MetadataKey\");\n\n            if (!key.valueType.isInstance(obj))\n                throw new IllegalArgumentException(\"Value of type \" + obj.getClass() +\n                                                   \" is incompatible with type for key \" + key +\n                                                   \" (\" + key.valueType + \")\");\n\n            extensions.put(key, obj);\n            modifiedKeys.add(key);\n            return this;\n        }\n\n        public Transformer withIfAbsent(ExtensionKey<?, ?> key, ExtensionValue<?> obj)\n        {\n            if (extensions.containsKey(key))\n                return this;\n            return with(key, obj);\n        }","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/ClusterMetadata.java#L918-L954","documentation":"ClusterMetadataTransformer.with(key, value) is only for extension (non-core) metadata. Passing a key registered in MetadataKeys.CORE_METADATA (schema, partitioner, directory, etc.) is rejected because core objects must be modified via their dedicated Transformer methods.","triggerScenarios":"Calling ClusterMetadata.Transformer.with(ExtensionKey, ExtensionValue) with a key that is one of the core metadata keys contained in MetadataKeys.CORE_METADATA.","commonSituations":"Plugin/extension code mistakenly reusing a core key as an ExtensionKey, or refactoring that switched a dedicated transformer call (e.g. schema()) to the generic with() path.","solutions":["Use the dedicated core transformer methods (e.g. schema(), partitioner(), directory()) instead of with().","Define a genuinely new ExtensionKey for custom metadata rather than reusing core keys.","Check MetadataKeys.CORE_METADATA to see which keys are reserved."],"exampleFix":"// before\ntransformer.with(MetadataKeys.SCHEMA, newSchema); // IllegalArgumentException\n// after\ntransformer.schema(newSchema);","handlingStrategy":"validation","validationCode":"if (MetadataKeys.CORE_METADATA.containsKey(key))\n    throw new IllegalArgumentException(\"Use dedicated core transformer methods for \" + key);","typeGuard":null,"tryCatchPattern":"try {\n    transformer.with(key, value);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Cannot use with() for core metadata: {}\", e.getMessage());\n}","preventionTips":["Use dedicated methods (schema(), partitioner(), etc.) for core metadata","Check MetadataKeys.CORE_METADATA before using with()","Reserve with()/without() strictly for custom ExtensionKeys"],"tags":["cassandra","tcm","transformer","api-misuse"],"backgroundTag":"invalid-argument-value","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"}