{"record":{"id":"5b0079e8ce98ad74","repo":"apache/cassandra","slug":"configuration-must-specify-either-node-proximity-a","errorCode":null,"errorMessage":"Configuration must specify either node_proximity and initial_location_provider or endpoint_snitch but not both. ","messagePattern":"Configuration must specify either node_proximity and initial_location_provider or endpoint_snitch but not both\\. ","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":1777,"sourceCode":"            }\n\n            for (String token : tokens)\n                partitioner.getTokenFactory().validate(token);\n        }\n        else if (conf.num_tokens == null)\n        {\n            conf.num_tokens = 1;\n        }\n    }\n\n    // definitely not safe for tools + clients - implicitly instantiates StorageService\n    public static void applySnitch()\n    {\n        boolean hasLegacyConfig = conf.endpoint_snitch != null;\n        boolean hasModernConfig = conf.initial_location_provider != null && conf.node_proximity != null;\n\n        if (hasLegacyConfig == hasModernConfig)\n            throw new ConfigurationException(\"Configuration must specify either node_proximity and \" +\n                                             \"initial_location_provider or endpoint_snitch but not both. \");\n\n        NodeProximity proximity;\n        NodeAddressConfig addressConfig;\n        if (hasLegacyConfig)\n        {\n            logger.info(\"Use of endpoint_snitch in configuration is deprecated and should be replaced by \" +\n                        \"initial_location_provider and node_proximity\");\n            SnitchAdapter adapter = new SnitchAdapter(createEndpointSnitch(conf.endpoint_snitch));\n            proximity = adapter;\n            initialLocationProvider = adapter;\n            addressConfig = adapter;\n        }\n        else\n        {\n            proximity = createProximityImpl(conf.node_proximity);\n            initialLocationProvider = createInitialLocationProvider(conf.initial_location_provider);\n            addressConfig = conf.addresses_config != null","sourceCodeStart":1759,"sourceCodeEnd":1795,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L1759-L1795","documentation":"Cassandra supports two ways to configure node placement: the legacy endpoint_snitch setting or the newer initial_location_provider plus node_proximity pair. applySnitch() rejects the config when both or neither form is present (hasLegacyConfig == hasModernConfig), because it cannot decide which snitch/proximity mechanism to instantiate.","triggerScenarios":"cassandra.yaml (or Config) has both endpoint_snitch and (initial_location_provider with node_proximity) set, or has neither; DatabaseDescriptor.applySnitch() throws ConfigurationException at startup.","commonSituations":"Upgrading to a version that introduced initial_location_provider/node_proximity while the old endpoint_snitch line was left in the yaml; partially migrating config where only one of the two modern keys was added; fresh installs missing any snitch configuration.","solutions":["Keep only one scheme: remove endpoint_snitch and set both initial_location_provider and node_proximity, or remove both modern keys and keep endpoint_snitch","If you intended the legacy snitch, add endpoint_snitch (e.g. SimpleSnitch) and delete the modern keys","If you intended the modern scheme, ensure BOTH initial_location_provider and node_proximity are set — one alone still counts as no modern config"],"exampleFix":"# before (cassandra.yaml)\nendpoint_snitch: SimpleSnitch\ninitial_location_provider: DefaultLocationProvider\nnode_proximity: DefaultProximity\n# after (choose one)\nendpoint_snitch: SimpleSnitch\n# or, without the endpoint_snitch line:\ninitial_location_provider: DefaultLocationProvider\nnode_proximity: DefaultProximity","handlingStrategy":"validation","validationCode":"if (hasLegacy == hasModern) throw new IllegalStateException(\"pick one snitch scheme\");","typeGuard":null,"tryCatchPattern":"try { DatabaseDescriptor.applySnitch(); } catch (ConfigurationException e) { /* keep one scheme */ }","preventionTips":["Use only one snitch configuration scheme"],"tags":["configuration","snitch","startup","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","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"}