{"record":{"id":"2bfec0d12f917785","repo":"git-ecosystem/git-credential-manager","slug":"failed-to-find-location-service","errorCode":null,"errorMessage":"Failed to find location service","messagePattern":"Failed to find location service","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Microsoft.AzureRepos/AzureDevOpsRestApi.cs","lineNumber":184,"sourceCode":"\n            _context.Trace.WriteLine($\"HTTP: GET {requestUri}\");\n            using (HttpRequestMessage request = CreateRequestMessage(HttpMethod.Get, requestUri, bearerToken: accessToken))\n            using (HttpResponseMessage response = await HttpClient.SendAsync(request))\n            {\n                _context.Trace.WriteLine($\"HTTP: Response {(int)response.StatusCode} [{response.StatusCode}]\");\n                if (response.IsSuccessStatusCode)\n                {\n                    string responseText = await response.Content.ReadAsStringAsync();\n\n                    if (TryGetFirstJsonStringField(responseText, \"location\", out string identityServiceStr) &&\n                        Uri.TryCreate(identityServiceStr, UriKind.Absolute, out Uri identityService))\n                    {\n                        return identityService;\n                    }\n                }\n            }\n\n            throw new Trace2Exception(_context.Trace2, \"Failed to find location service\");\n        }\n\n        #endregion\n\n        #region Request and Response Helpers\n\n        private const RegexOptions CommonRegexOptions = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;\n\n        private HttpClient _httpClient;\n\n        private HttpClient HttpClient\n        {\n            get\n            {\n                if (_httpClient is null)\n                {\n                    _httpClient = _context.HttpClientFactory.CreateClient();\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Microsoft.AzureRepos/AzureDevOpsRestApi.cs#L166-L202","documentation":"GetIdentityServiceUriAsync throws this Trace2Exception when it cannot locate the Azure DevOps location service for the given organization URI. The location service is the discovery endpoint used to find the identity service URI; without it, PAT creation cannot proceed. This usually means the organization URL is wrong or the server did not return the expected location service resource.","triggerScenarios":"Calling GetIdentityServiceUriAsync (via CreatePersonalAccessTokenAsync) when iterating the location service resources for the organization URI yields no valid identity service — e.g. the API returns success but no matching location service entry.","commonSituations":"Typo'd or malformed organization URL (not an Azure DevOps host); self-hosted Azure DevOps Server instances exposing a different API surface; proxies or firewalls stripping the discovery response; org renamed/deleted.","solutions":["Verify the organization URL is a valid Azure DevOps endpoint (https://dev.azure.com/<org> or a valid Azure DevOps Server URL)","Open the organization URL in a browser to confirm the org exists","Check for proxy/firewall interference with the discovery request","If using Azure DevOps Server, confirm the server version is supported by this GCM version"],"exampleFix":"// before\nawait repo.Fetch(remote); // remote: http://git.internal.example/scm/proj/repo\n// after\nawait repo.Fetch(remote); // remote: https://dev.azure.com/myorg/proj/_git/repo (valid Azure DevOps URL)","handlingStrategy":"validation","validationCode":"// C#\nvar candidate = new Uri(\"https://dev.azure.com/myorg\");\nif (!candidate.Host.Equals(\"dev.azure.com\", StringComparison.OrdinalIgnoreCase) &&\n    !candidate.Host.EndsWith(\".visualstudio.com\", StringComparison.OrdinalIgnoreCase))\n    throw new ArgumentException(\"URL is not an Azure DevOps endpoint\");","typeGuard":null,"tryCatchPattern":"try {\n    var identityUri = await api.GetIdentityServiceUriAsync(orgUri, token);\n} catch (Trace2Exception) {\n    // prompt user to verify org URL / connectivity before retry\n}","preventionTips":["Always use fully qualified https://dev.azure.com/<org> URLs","Test the org URL in a browser before configuring remotes","Check proxy/firewall allowlists for Azure DevOps endpoints","For Azure DevOps Server, verify server version compatibility"],"tags":["azure-devops","location-service","url","discovery"],"backgroundTag":"resource-not-found","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}