{"record":{"id":"b5385b60302e6372","repo":"apache/cassandra","slug":"config-contains-both-old-and-new-keys-for-the-same-b5385b","errorCode":null,"errorMessage":"Config contains both old and new keys for the same configuration parameters, migrate old -> new: %s","messagePattern":"Config contains both old and new keys for the same configuration parameters, migrate old -> new: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/YamlConfigurationLoader.java","lineNumber":312,"sourceCode":"        {\n            for (Map.Entry<String, Replacement> entry : outerEntry.getValue().entrySet())\n            {\n                Replacement r = entry.getValue();\n                if (!r.isValueFormatReplacement() && rawConfig.containsKey(r.oldName) && rawConfig.containsKey(r.newName))\n                {\n                    String msg = String.format(\"[%s -> %s]\", r.oldName, r.newName);\n                    duplicates.add(msg);\n                }\n            }\n        }\n\n        if (!duplicates.isEmpty())\n        {\n            String msg = String.format(\"Config contains both old and new keys for the same configuration parameters, migrate old -> new: %s\", String.join(\", \", duplicates));\n            if (!ALLOW_NEW_OLD_CONFIG_KEYS.getBoolean())\n                throw new ConfigurationException(msg);\n            else\n                logger.warn(msg);\n        }\n    }\n\n    private static void verifyReplacements(Map<Class<?>, Map<String, Replacement>> replacements, byte[] configBytes)\n    {\n        LoaderOptions loaderOptions = getDefaultLoaderOptions();\n        loaderOptions.setAllowDuplicateKeys(ALLOW_DUPLICATE_CONFIG_KEYS.getBoolean());\n        Yaml rawYaml = new Yaml(loaderOptions);\n\n        Map<String, Object> rawConfig = rawYaml.load(new ByteArrayInputStream(configBytes));\n        if (rawConfig == null)\n            rawConfig = new HashMap<>();\n        verifyReplacements(replacements, rawConfig);\n\n    }\n\n    @VisibleForTesting\n    public static <T> T fromMap(Map<String,Object> map, Class<T> klass)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java#L294-L330","documentation":"Cassandra renamed many cassandra.yaml keys (old snake_case or legacy names replaced by new canonical ones). YamlConfigurationLoader.verifyReplacements() detects when both the old and the new key for the same parameter appear in the config, which is ambiguous. Unless the flag cassandra.allow_new_old_config_keys is set, it throws ConfigurationException and refuses to start; otherwise it logs this warning.","triggerScenarios":"cassandra.yaml contains e.g. both commitlog_sync_period_in_ms and commitlog_sync_period (old+new pair) for any renamed parameter; raised during loadConfig -> verifyReplacements at startup or config reload. Setting -Dcassandra.allow_new_old_config_keys=true downgrades to a warning.","commonSituations":"Upgrades where tools merge old and new yaml templates; copy-pasting snippets from both old and new documentation; config management systems (Puppet/Ansible) layering templates from different Cassandra versions.","solutions":["Remove the old key(s) and keep only the new canonical name listed in the message","If temporarily unavoidable, start with -Dcassandra.allow_new_old_config_keys=true to downgrade to a warning, then migrate promptly","Check conf/yaml aliases for the version to map each old key to its replacement"],"exampleFix":"// cassandra.yaml before\ncommitlog_sync_period_in_ms: 10000\ncommitlog_sync_period: 10000ms\n// after\ncommitlog_sync_period: 10000ms","handlingStrategy":"try-catch","validationCode":"// diff config against the version's allowed keys before deploy\nSet<String> allowed = allowedKeysForVersion(targetVersion);\nSet<String> present = readTopLevelYamlKeys(Path.of(\"conf/cassandra.yaml\"));\nSet<String> stale = new HashSet<>(present); stale.removeAll(allowed);\nif (!stale.isEmpty()) throw new IllegalStateException(\"Remove old keys: \" + stale);","typeGuard":null,"tryCatchPattern":"try { DatabaseDescriptor.daemonInitialization(); } catch (ConfigurationException e) { if (e.getMessage().contains(\"migrate old -> new\")) { /* fix yaml keys, restart */ } throw e; }","preventionTips":["Only allow one name per parameter in yaml templates","Run config lint against the target Cassandra version's replacement map in CI","Avoid layering templates from different Cassandra versions in config management","Never rely on cassandra.allow_new_old_config_keys in production"],"tags":["cassandra","yaml","configuration","deprecated-keys"],"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-17T15:17:12.973Z"}