{"record":{"id":"4ba00cd29af4e1ed","repo":"git-ecosystem/git-credential-manager","slug":"cannot-determine-the-organization-name-for-this-d","errorCode":null,"errorMessage":"Cannot determine the organization name for this 'dev.azure.com' remote URL. Ensure the `credential.useHttpPath` configuration value is set, or set the organization name as the user in the remote URL '{org}@dev.azure.com'.","messagePattern":"Cannot determine the organization name for this 'dev\\.azure\\.com' remote URL\\. Ensure the `credential\\.useHttpPath` configuration value is set, or set the organization name as the user in the remote URL '(.+?)@dev\\.azure\\.com'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.AzureRepos/UriHelpers.cs","lineNumber":165,"sourceCode":"            // The older *.visualstudio.com URLs contained the organization name in the host already.\n            if (IsDevAzureComHost(remoteUri.Host))\n            {\n                string firstPathComponent = GetFirstPathComponent(remoteUri.AbsolutePath);\n                string remoteUriUserName = remoteUri.GetUserName();\n\n                // Prefer getting the org name from the path: dev.azure.com/{org}\n                if (!string.IsNullOrWhiteSpace(firstPathComponent))\n                {\n                    orgName = firstPathComponent;\n                }\n                // Failing that try using the username: {org}@dev.azure.com\n                else if (!string.IsNullOrWhiteSpace(remoteUriUserName))\n                {\n                    orgName = remoteUriUserName;\n                }\n                else\n                {\n                    throw new InvalidOperationException(\n                        \"Cannot determine the organization name for this 'dev.azure.com' remote URL. \" +\n                        \"Ensure the `credential.useHttpPath` configuration value is set, or set the organization \" +\n                        \"name as the user in the remote URL '{org}@dev.azure.com'.\"\n                    );\n                }\n\n                ub.Path = orgName;\n            }\n            else if (IsVisualStudioComHost(remoteUri.Host))\n            {\n                // {org}.visualstudio.com\n                int orgNameLength = remoteUri.Host.Length - AzureDevOpsConstants.VstsHostSuffix.Length;\n                orgName = remoteUri.Host.Substring(0, orgNameLength);\n            }\n\n            return ub.Uri;\n        }\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Microsoft.AzureRepos/UriHelpers.cs#L147-L183","documentation":"UriHelpers.CreateOrganizationUri throws this InvalidOperationException when the remote is a dev.azure.com URL but the organization name cannot be extracted: unlike visualstudio.com URLs (org.visualstudio.com), dev.azure.com embeds the org as the first path segment, and if credential.useHttpPath is disabled and the URL has no '{org}@' user info, there is no reliable source for the organization. The library fails loudly rather than guessing.","triggerScenarios":"Calling GetOrganizationName on a URL like https://dev.azure.com (or one whose first path segment is missing/unusable) when credential.useHttpPath is not enabled and the remote URL carries no username ('{org}@dev.azure.com') from which to read the organization.","commonSituations":"Very short dev.azure.com URLs like https://dev.azure.com/org that GCM's URL trimming normalizes past the org segment; users migrating from org.visualstudio.com URLs to dev.azure.com without enabling useHttpPath; tooling constructing bare https://dev.azure.com URIs programmatically; GCM_HINT/GCM settings lacking credential.useHttpPath=true.","solutions":["Enable the recommended config: git config --global credential.useHttpPath true (or GCM_SETTING / credential.useHttpPath in the repo).","Embed the organization as the username in the remote URL: git remote set-url origin https://ORG@dev.azure.com/ORG/Project/_git/repo.","Prefer the legacy-style URL form org.visualstudio.com where the org is part of the host, which is unambiguous.","When calling the API directly, pass a dev.azure.com URI whose first path segment is the organization and ensure the request reflects useHttpPath or a remote user."],"exampleFix":"// before\ngit remote set-url origin https://dev.azure.com/acme/Project/_git/repo  // org not discoverable\n// after (either fix works)\ngit config --global credential.useHttpPath true\ngit remote set-url origin https://acme@dev.azure.com/acme/Project/_git/repo","handlingStrategy":"validation","validationCode":"var uri = new Uri(remoteUri);\nif (uri.Host.Equals(\"dev.azure.com\", StringComparison.OrdinalIgnoreCase))\n{\n    var hasOrgPath = uri.AbsolutePath.Split('/', StringSplitOptions.RemoveEmptyEntries).Length >= 1;\n    var hasOrgUser = !string.IsNullOrEmpty(uri.UserInfo);\n    var useHttpPath = /* read git config credential.useHttpPath */ hasOrgUser;\n    if (!hasOrgUser && !hasOrgPath)\n        throw new InvalidOperationException(\"Set credential.useHttpPath=true or use https://org@dev.azure.com/... so the organization is discoverable.\");\n}","typeGuard":"static bool OrganizationIsDiscoverable(Uri remoteUri, bool useHttpPath) =>\n    !remoteUri.Host.Equals(\"dev.azure.com\", StringComparison.OrdinalIgnoreCase) // unambiguous host forms\n    || !string.IsNullOrEmpty(remoteUri.UserInfo)                                  // {org}@dev.azure.com\n    || useHttpPath;                                                                // org taken from http path","tryCatchPattern":"try { return UriHelpers.GetOrganizationName(remoteUri); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Cannot determine the organization name\"))\n{\n    // prompt user to enable credential.useHttpPath or add {org}@ to the remote URL\n    return null;\n}","preventionTips":["Set git config --global credential.useHttpPath true for dev.azure.com remotes.","Include the org as the username in dev.azure.com remotes: https://org@dev.azure.com/org/Project/_git/repo.","Avoid bare https://dev.azure.com URLs when constructing requests programmatically; always include the org path segment.","When migrating from org.visualstudio.com to dev.azure.com, update credential config in the same change."],"tags":["azure-devops","git-credentials","url-parsing","missing-config"],"backgroundTag":"missing-config-value","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"}