{"record":{"id":"fadea672719628ed","repo":"apache/cassandra","slug":"provided-datacenter-s-is-not-a-valid-datacenter","errorCode":null,"errorMessage":"Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s","messagePattern":"Provided datacenter '(.+?)' is not a valid datacenter, available datacenters are: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/Rebuild.java","lineNumber":90,"sourceCode":"        isRebuilding.set(false);\n    }\n\n    public static void rebuild(String sourceDc, String keyspace, String tokens, String specificSources, boolean excludeLocalDatacenterNodes)\n    {\n        // check ongoing rebuild\n        if (!isRebuilding.compareAndSet(false, true))\n        {\n            throw new IllegalStateException(\"Node is still rebuilding. Check nodetool netstats.\");\n        }\n\n        if (sourceDc != null)\n        {\n            if (sourceDc.equals(DatabaseDescriptor.getLocalDataCenter()) && excludeLocalDatacenterNodes) // fail if source DC is local and --exclude-local-dc is set\n                throw new IllegalArgumentException(\"Cannot set source data center to be local data center, when excludeLocalDataCenter flag is set\");\n            Set<String> availableDCs = ClusterMetadata.current().directory.knownDatacenters();\n            if (!availableDCs.contains(sourceDc))\n            {\n                throw new IllegalArgumentException(String.format(\"Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s\",\n                                                                 sourceDc, String.join(\",\", availableDCs)));\n            }\n        }\n\n        try\n        {\n            // check the arguments\n            if (keyspace == null && tokens != null)\n            {\n                throw new IllegalArgumentException(\"Cannot specify tokens without keyspace.\");\n            }\n\n            logger.info(\"rebuild from dc: {}, {}, {}\", sourceDc == null ? \"(any dc)\" : sourceDc,\n                        keyspace == null ? \"(All keyspaces)\" : keyspace,\n                        tokens == null ? \"(All tokens)\" : tokens);\n\n            StorageService.instance.repairPaxosForTopologyChange(\"rebuild\");\n            ClusterMetadata metadata = ClusterMetadata.current();","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/Rebuild.java#L72-L108","documentation":"rebuild checks the supplied sourceDc against the datacenters known to cluster metadata (ClusterMetadata.current().directory.knownDatacenters()) and rejects unknown names, listing the valid alternatives.","triggerScenarios":"rebuild(sourceDc=<name>, ...) where <name> is not in the set of known datacenters.","commonSituations":"Typo in DC name (`us-east` vs `us_east`); DC renamed or decommissioned; running rebuild before the new DC is fully registered; case mismatch in DC names.","solutions":["Run `nodetool describecluster` or check the error message's list and use an exact datacenter name","Correct the DC name casing/spelling to match the cluster metadata","Ensure the target DC's nodes are joined and visible in gossip/cluster metadata before rebuilding"],"exampleFix":"// before\nnodetool rebuild -- Us-East\n// after\nnodetool rebuild -- us-east","handlingStrategy":"validation","validationCode":"Set<String> known = ClusterMetadata.current().directory.knownDatacenters();\nif (!known.contains(sourceDc))\n    throw new IllegalArgumentException(\"unknown DC \" + sourceDc + \"; valid: \" + known);","typeGuard":null,"tryCatchPattern":"try { rebuild(sourceDc, ...); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Provided datacenter\")) rebuild(correctDcFrom(e.getMessage()), ...); else throw e; }","preventionTips":["Copy DC names from `nodetool describecluster` / system.peers rather than typing them","Standardize DC naming conventions (no case variants)","Confirm the target DC's nodes are joined before rebuilding"],"tags":["configuration","datacenter","validation","rebuild"],"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-14T21:17:11.552Z"}