git-ecosystem / git-credential-manager

Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, and other popular Git hosting services.
Other
6.76k stars 1.76k forks source link

GCM fails to get the Azure organization name from the URL username #1520

Closed SpecLad closed 7 months ago

SpecLad commented 8 months ago

Version

2.4.1

Operating system

Windows

OS version or distribution

Windows 11 22H2 (x64)

Git hosting provider(s)

Azure DevOps

Other hosting provider

No response

(Azure DevOps only) What format is your remote URL?

https://{org}@dev.azure.com/{org}

Can you access the remote repository directly in the browser?

Yes, I can access the repository

Expected behavior

GCM should open an Azure login dialog.

Actual behavior

GCM outputs the following message:

fatal: 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'.

Logs

> git ls-remote https://redacted@dev.azure.com/redacted/redacted/_git/redacted

01:01:11.347318 exec-cmd.c:244          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
01:01:11.352318 git.c:463               trace: built-in: git ls-remote https://redacted@dev.azure.com/redacted/redacted/_git/redacted
01:01:11.352318 run-command.c:659       trace: run_command: git remote-https https://redacted@dev.azure.com/redacted/redacted/_git/redacted https://redacted@dev.azure.com/redacted/redacted/_git/redacted
01:01:11.363319 exec-cmd.c:244          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:11.364320 git.c:749               trace: exec: git-remote-https https://redacted@dev.azure.com/redacted/redacted/_git/redacted https://redacted@dev.azure.com/redacted/redacted/_git/redacted
01:01:11.364320 run-command.c:659       trace: run_command: git-remote-https https://redacted@dev.azure.com/redacted/redacted/_git/redacted https://redacted@dev.azure.com/redacted/redacted/_git/redacted
01:01:11.373799 exec-cmd.c:244          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:12.613138 run-command.c:659       trace: run_command: 'git credential-manager get'
01:01:12.651673 exec-cmd.c:244          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:12.653673 git.c:749               trace: exec: git-credential-manager get
01:01:12.653673 run-command.c:659       trace: run_command: git-credential-manager get
01:01:12.718171 exec-cmd.c:244          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
01:01:12.720190 git.c:463               trace: built-in: git config --null --list
01:01:12.768692 ...\Application.cs:106  trace: [RunInternalAsync] Version: 2.4.1.0
01:01:12.777363 ...\Application.cs:107  trace: [RunInternalAsync] Runtime: .NET Framework 4.8.9181.0
01:01:12.777363 ...\Application.cs:108  trace: [RunInternalAsync] Platform: Windows (x86-64)
01:01:12.777363 ...\Application.cs:109  trace: [RunInternalAsync] OSVersion: 10.0 (build 22621)
01:01:12.777363 ...\Application.cs:110  trace: [RunInternalAsync] AppPath: C:\Program Files\Git\mingw64\bin\git-credential-manager.exe
01:01:12.777363 ...\Application.cs:111  trace: [RunInternalAsync] InstallDir: C:\Program Files\Git\mingw64\bin\
01:01:12.777363 ...\Application.cs:112  trace: [RunInternalAsync] Arguments: get
01:01:12.811407 ...GitCommandBase.cs:32 trace: [ExecuteAsync] Start 'get' command...
01:01:12.820436 ...GitCommandBase.cs:46 trace: [ExecuteAsync] Detecting host provider for input:
01:01:12.822433 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   protocol=https
01:01:12.822433 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   host=dev.azure.com
01:01:12.822433 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   username=redacted
01:01:12.822433 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   wwwauth[]=Bearer authorization_uri=https://login.microsoftonline.com/42cc3295-cd0e-449c-b98e-5ce5b560c1d3
01:01:12.822433 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   wwwauth[]=Basic realm="https://tfsprodcus1.app.visualstudio.com/"
01:01:12.823414 ...GitCommandBase.cs:47 trace: [ExecuteAsync]   wwwauth[]=TFS-Federated
01:01:12.826438 ...viderRegistry.cs:149 trace: [GetProviderAsync] Performing auto-detection of host provider.
01:01:12.826438 ...viderRegistry.cs:162 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
01:01:12.827965 ...viderRegistry.cs:170 trace: [GetProviderAsync] Checking against 4 host providers registered with priority 'Normal'.
01:01:12.828995 ...GitCommandBase.cs:49 trace: [ExecuteAsync] Host provider 'Azure Repos' was selected.
fatal: 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'.
   в Microsoft.AzureRepos.UriHelpers.CreateOrganizationUri(Uri remoteUri, String& orgName)
   в Microsoft.AzureRepos.AzureReposHostProvider.GetServiceName(Uri remoteUri)
   в Microsoft.AzureRepos.AzureReposHostProvider.<GetCredentialAsync>d__15.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   в GitCredentialManager.Commands.GetCommand.<ExecuteInternalAsync>d__1.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   в GitCredentialManager.Commands.GitCommandBase.<ExecuteAsync>d__5.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Invocation.AnonymousCommandHandler.<InvokeAsync>d__6.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<AddMiddleware>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   в System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()
01:01:12.862938 run-command.c:659       trace: run_command: bash -c 'cat >/dev/tty && read -r -s line </dev/tty && echo "$line" && echo >/dev/tty'
Password for 'https://redacted@dev.azure.com':
SpecLad commented 8 months ago

I suspect that the problem is that here:

https://github.com/git-ecosystem/git-credential-manager/blob/70c4dd02adce206a64a3b0a908cab39a37ae5651/src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs#L95

the includeUser parameter is not set to true.