{"record":{"id":"e0a4df14d28376ec","repo":"apache/cassandra","slug":"unable-to-retrieve-initial-location-from-cloud-met","errorCode":null,"errorMessage":"Unable to retrieve initial location from cloud metadata service. This is required for registration, please check configuration","messagePattern":"Unable to retrieve initial location from cloud metadata service\\. This is required for registration, please check configuration","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/AzureCloudLocationProvider.java","lineNumber":76,"sourceCode":"        super(connector, AzureCloudLocationProvider::resolveLocation);\n    }\n\n    static Location resolveLocation(AbstractCloudMetadataServiceConnector connector) throws IOException\n    {\n        String apiVersion = connector.getProperties().get(API_VERSION_PROPERTY_KEY, DEFAULT_API_VERSION);\n        String response = connector.apiCall(format(METADATA_QUERY_TEMPLATE, apiVersion),\n                                            ImmutableMap.of(METADATA_HEADER, \"true\"));\n        JsonNode jsonNode = JsonUtils.JSON_OBJECT_MAPPER.readTree(response);\n\n        JsonNode location = jsonNode.get(\"location\");\n        JsonNode zone = jsonNode.get(\"zone\");\n        JsonNode platformFaultDomain = jsonNode.get(\"platformFaultDomain\");\n\n        String datacenter;\n        String rack;\n\n        if (location == null || location.isNull() || location.asText().isEmpty())\n            throw new ConfigurationException(\"Unable to retrieve initial location from cloud metadata service. \" +\n                                             \"This is required for registration, please check configuration\");\n        else\n            datacenter = location.asText();\n\n        if (zone == null || zone.isNull() || zone.asText().isEmpty())\n        {\n            if (platformFaultDomain == null || platformFaultDomain.isNull() || platformFaultDomain.asText().isEmpty())\n            {\n                throw new ConfigurationException(\"Unable to retrieve initial zone or platform fault domain from cloud metadata service. \" +\n                                                 \"This is required for registration, please check configuration\");\n            }\n            else\n            {\n                rack = platformFaultDomain.asText();\n            }\n        }\n        else\n        {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/AzureCloudLocationProvider.java#L58-L94","documentation":"Thrown by AzureCloudLocationProvider.resolveLocation() when the Azure instance metadata service returned a response from which the location (region) field could not be extracted — null JSON node, JSON null, or empty text. A location (datacenter) is mandatory for snitch registration, so startup fails with a ConfigurationException.","triggerScenarios":"Node startup with azure.CloudStack/Azure location provider where the metadata call succeeds but the region field is missing/empty — e.g. endpoint misconfigured, non-Azure VM, or IMDS response shape changed.","commonSituations":"Running a Cassandra node on a non-Azure machine configured with the Azure location provider; Azure IMDS unreachable/proxied so the resolver parses an empty or partial response; wrong metadata service URL override in cassandra.yaml.","solutions":["Verify the node actually runs in Azure and the IMDS endpoint (169.254.169.254) is reachable","Check cassandra.yaml azure metadata connector settings (endpoint URL, timeouts)","Ensure the location/region property name configured for the provider matches the Azure compute metadata response","Remove the Azure cloud provider config if the node is not in Azure"],"exampleFix":"# before\ncassandra.cloud_metadata_service_endpoint: http://wrong-host/metadata/instance\n\n# after\ncassandra.cloud_metadata_service_endpoint: http://169.254.169.254/metadata/instance?api-version=2021-02-01","handlingStrategy":"try-catch","validationCode":"// pre-check on the node before startup\ncurl -H Metadata:true \"http://169.254.169.254/metadata/instance/compute?api-version=2021-02-01\" | grep -i location","typeGuard":null,"tryCatchPattern":"try { location = provider.resolveLocation(connector); } catch (ConfigurationException e) { logger.error(\"Azure metadata location missing; check IMDS\", e); throw e; }","preventionTips":["Only enable the Azure location provider on Azure VMs","Pin a recent IMDS api-version","Smoke-test metadata access in the node's startup healthcheck"],"tags":["azure","cloud-metadata","snitch","configuration"],"backgroundTag":"missing-config-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"}