{"record":{"id":"5efc19da51a6d2eb","repo":"apache/cassandra","slug":"cloudstacksnitch-cannot-handle-invalid-zone-format","errorCode":null,"errorMessage":"CloudstackSnitch cannot handle invalid zone format: %s","messagePattern":"CloudstackSnitch cannot handle invalid zone format: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/CloudstackLocationProvider.java","lineNumber":77,"sourceCode":"    public CloudstackLocationProvider(SnitchProperties snitchProperties) throws IOException\n    {\n        this(new DefaultCloudMetadataServiceConnector(snitchProperties.putIfAbsent(METADATA_URL_PROPERTY, csMetadataEndpoint())));\n    }\n\n    public CloudstackLocationProvider(AbstractCloudMetadataServiceConnector connector) throws IOException\n    {\n        super(connector, CloudstackLocationProvider::resolveLocation);\n        logger.warn(\"{} is deprecated and not actively maintained. It will be removed in the next \" +\n                    \"major version of Cassandra.\", CloudstackSnitch.class.getName());\n    }\n\n    private static Location resolveLocation(AbstractCloudMetadataServiceConnector connector) throws IOException\n    {\n        String zone = connector.apiCall(ZONE_NAME_QUERY_URI);\n        String[] zoneParts = zone.split(\"-\");\n\n        if (zoneParts.length != 3)\n            throw new ConfigurationException(\"CloudstackSnitch cannot handle invalid zone format: \" + zone);\n\n        return new Location(zoneParts[0] + '-' + zoneParts[1], zoneParts[2]);\n    }\n\n    private static String csMetadataEndpoint() throws ConfigurationException\n    {\n        for (String lease_uri : LEASE_FILES)\n        {\n            try\n            {\n                File lease_file = new File(new URI(lease_uri));\n                if (lease_file.exists())\n                {\n                    return csEndpointFromLease(lease_file);\n                }\n            }\n            catch (Exception e)\n            {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/CloudstackLocationProvider.java#L59-L95","documentation":"Thrown by CloudstackLocationProvider.resolveLocation() when the CloudStack metadata zone string does not split into exactly three '-'-separated parts. CloudstackSnitch expects zone format like 'pods-cloud1-host1' where the first two parts form the datacenter and the third the rack; anything else is rejected with a ConfigurationException.","triggerScenarios":"Node startup with the Cloudstack location provider where the ZONE_NAME_QUERY_URI api call returns a zone string with a different number of hyphen-separated segments.","commonSituations":"Custom CloudStack zone names containing extra hyphens or none; querying the wrong metadata endpoint returning HTML/an error page; non-CloudStack environment misconfigured with the Cloudstack provider.","solutions":["Rename the CloudStack zone to the expected 3-part hyphenated format (cloud-pod-host)","Verify the metadata endpoint returns only the raw zone name (curl the ZONE_NAME_QUERY_URI)","Use a different snitch/location provider if the environment is not CloudStack"],"exampleFix":"// before: zone \"myZone\" (1 part)\n// after: rename CloudStack zone to expected format, e.g. \"pods-cloud1-host1\"\n// -> datacenter \"pods-cloud1\", rack \"host1\"","handlingStrategy":"validation","validationCode":"String zone = connector.apiCall(ZONE_NAME_QUERY_URI);\nif (zone == null || zone.split(\"-\").length != 3) throw new IllegalArgumentException(\"Unexpected zone format: \" + zone);","typeGuard":null,"tryCatchPattern":"try { location = CloudstackLocationProvider.resolveLocation(connector); } catch (ConfigurationException e) { logger.error(\"Bad CloudStack zone format\", e); throw e; }","preventionTips":["Enforce the cloud-pod-host naming convention for CloudStack zones","Test the metadata zone endpoint returns a bare zone string","Only use the Cloudstack provider on CloudStack infrastructure"],"tags":["cloudstack","snitch","format-validation"],"backgroundTag":"invalid-argument-format","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"}