{"record":{"id":"da4f881794052700","repo":"git-ecosystem/git-credential-manager","slug":"host-is-not-azure-devops","errorCode":null,"errorMessage":"Host is not Azure DevOps.","messagePattern":"Host is not Azure DevOps\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.AzureRepos/AzureReposHostProvider.cs","lineNumber":469,"sourceCode":"        {\n            // dev.azure.com\n            if (UriHelpers.IsDevAzureComHost(remoteUri.Host))\n            {\n                // We can never store the new dev.azure.com-style URLs against the full path because\n                // we have forced the useHttpPath option to true to in order to retrieve the AzDevOps\n                // organization name from Git.\n                return UriHelpers.CreateOrganizationUri(remoteUri, out _).AbsoluteUri.TrimEnd('/');\n            }\n\n            // *.visualstudio.com\n            if (UriHelpers.IsVisualStudioComHost(remoteUri.Host))\n            {\n                // If we're given the full path for an older *.visualstudio.com-style URL then we should\n                // respect that in the service name.\n                return remoteUri.WithoutUserInfo().AbsoluteUri.TrimEnd('/');\n            }\n\n            throw new InvalidOperationException(\"Host is not Azure DevOps.\");\n        }\n\n        private static string GetAccountNameForCredentialQuery(GitRequest request)\n        {\n            if (!request.TryGetHostAndPort(out string hostName, out _))\n            {\n                throw new InvalidOperationException(\"Failed to parse host name and/or port\");\n            }\n\n            // dev.azure.com\n            if (UriHelpers.IsDevAzureComHost(hostName))\n            {\n                // We ignore the given username for dev.azure.com-style URLs because AzDevOps recommends\n                // adding the organization name as the user in the remote URL (resulting in URLs like\n                // https://org@dev.azure.com/org/foo/_git/bar) and we don't know if the given username\n                // is an actual username, or the org name.\n                // Use `null` as the account name so we match all possible credentials (regardless of\n                // the account).","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Microsoft.AzureRepos/AzureReposHostProvider.cs#L451-L487","documentation":"GetServiceName throws this InvalidOperationException when the remote URI does not match any recognized Azure DevOps host pattern (dev.azure.com or *.visualstudio.com) and is not a full-path legacy visualstudio.com URL. It is an internal invariant: the provider should only be invoked for Azure DevOps remotes, so reaching this line means the host check upstream failed.","triggerScenarios":"Calling the Service property on AzureReposHostProvider (GetServiceName) with a remoteUri whose host is not dev.azure.com, *.visualstudio.com, and does not qualify as a full-path legacy URL.","commonSituations":"Misconfigured host provider selection (Azure DevOps provider used for GitHub/GitLab/Bitbucket remotes); typo'd host in the remote URL; custom provider routing sending non-AzDO URLs to this provider.","solutions":["Verify the remote URL is genuinely an Azure DevOps URL and fix it: git remote set-url origin https://dev.azure.com/<org>/<project>/_git/<repo>","Check credential.provider or GCM provider configuration so the correct host provider handles this remote (e.g. set provider to github/gitlab/generic for non-AzDO hosts)","Clear stale config forcing the azure provider: git config --unset credential.https://<host>.credentialProvider"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// C#\nstatic bool IsAzureDevOpsHost(Uri u) =>\n    u.Host.Equals(\"dev.azure.com\", StringComparison.OrdinalIgnoreCase) ||\n    u.Host.EndsWith(\".visualstudio.com\", StringComparison.OrdinalIgnoreCase);","typeGuard":"static bool IsAzureDevOpsRemote(Uri remoteUri) =>\n    remoteUri.Host.Equals(\"dev.azure.com\", StringComparison.OrdinalIgnoreCase) ||\n    remoteUri.Host.EndsWith(\".visualstudio.com\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try {\n    var service = provider.Service;\n} catch (InvalidOperationException ex) when (ex.Message == \"Host is not Azure DevOps.\") {\n    // route to the correct host provider (github/gitlab/generic)\n}","preventionTips":["Ensure only Azure DevOps remotes are routed to the azure host provider","Fix remote URLs that point to non-AzDO hosts","Avoid hardcoding credential.provider globally; scope it per-host"],"tags":["azure-devops","host-provider","remote-url","invariant"],"backgroundTag":"internal-invariant-violation","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"}