git-ecosystem/git-credential-manager · error · Trace2Exception
Failed to find location service
Error message
Failed to find location service
What it means
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.
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
Example fix
// before await repo.Fetch(remote); // remote: http://git.internal.example/scm/proj/repo // after await repo.Fetch(remote); // remote: https://dev.azure.com/myorg/proj/_git/repo (valid Azure DevOps URL)
Defensive patterns
Strategy: validation
Validate before calling
// C#
var candidate = new Uri("https://dev.azure.com/myorg");
if (!candidate.Host.Equals("dev.azure.com", StringComparison.OrdinalIgnoreCase) &&
!candidate.Host.EndsWith(".visualstudio.com", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException("URL is not an Azure DevOps endpoint"); Try / catch
try {
var identityUri = await api.GetIdentityServiceUriAsync(orgUri, token);
} catch (Trace2Exception) {
// prompt user to verify org URL / connectivity before retry
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Provided URI ' ' is not a valid Azure DevOps hostname
- Failed to create PAT
- Failed to create PAT
- Unencrypted HTTP is not recommended for Azure Repos. Ensure…
- Host is not Azure DevOps.
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/2bfec0d12f917785.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.AzureRepos/AzureDevOpsRestApi.cs:184
_context.Trace.WriteLine($"HTTP: GET {requestUri}");
using (HttpRequestMessage request = CreateRequestMessage(HttpMethod.Get, requestUri, bearerToken: accessToken))
using (HttpResponseMessage response = await HttpClient.SendAsync(request))
{
_context.Trace.WriteLine($"HTTP: Response {(int)response.StatusCode} [{response.StatusCode}]");
if (response.IsSuccessStatusCode)
{
string responseText = await response.Content.ReadAsStringAsync();
if (TryGetFirstJsonStringField(responseText, "location", out string identityServiceStr) &&
Uri.TryCreate(identityServiceStr, UriKind.Absolute, out Uri identityService))
{
return identityService;
}
}
}
throw new Trace2Exception(_context.Trace2, "Failed to find location service");
}
#endregion
#region Request and Response Helpers
private const RegexOptions CommonRegexOptions = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
private HttpClient _httpClient;
private HttpClient HttpClient
{
get
{
if (_httpClient is null)
{
_httpClient = _context.HttpClientFactory.CreateClient();
View on GitHub (pinned to e8ce762cd0)