git-ecosystem/git-credential-manager · error · ArgumentOutOfRangeException

At least one AuthenticationModes must be supplied

Error message

At least one AuthenticationModes must be supplied

What it means

GetCredentialsViaTtyAsync (terminal prompt path) throws ArgumentOutOfRangeException when the resolved mode is AuthenticationModes.None, mirroring the up-front validation in GetCredentialsAsync. The terminal flow cannot prompt when no authentication mode is supplied.

Solutions

  1. Enable at least one auth mode in GCM settings (e.g. set GCM_BITBUCKET_AUTHMODES to Basic or OAuth)
  2. Pass a valid modes bitmask when calling GetCredentialsAsync directly
  3. Verify GetSupportedAuthenticationModesAsync inputs (host, settings) are not filtering out all modes

Example fix

// before
await auth.GetCredentialsAsync(uri, null, AuthenticationModes.None);
// after
await auth.GetCredentialsAsync(uri, null, AuthenticationModes.OAuth);
Defensive patterns

Strategy: validation

Validate before calling

if (modes == AuthenticationModes.None)
    modes = AuthenticationModes.Basic | AuthenticationModes.OAuth; // ensure at least one

Type guard

bool CanPrompt(AuthenticationModes m) => m != AuthenticationModes.None;

Try / catch

try { await auth.GetCredentialsAsync(uri, user, modes); }
catch (ArgumentOutOfRangeException ex) { trace.Error(ex); throw new InvalidOperationException("No auth mode configured", ex); }

Prevention

When it happens

Trigger: GetCredentialsAsync invoked without a GUI/desktop session so the TTY path runs, with modes == AuthenticationModes.None (e.g. all auth modes disabled in settings).

Common situations: Running git push/pull in a terminal with misconfigured GCM settings that disable every Bitbucket auth mode; scripting calls to GetCredentialsAsync with modes: None.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/67864daad194726a. Report an issue: GitHub.

Appendix: source

Thrown at src/Atlassian.Bitbucket/BitbucketAuthentication.cs:181

                    }
                    else
                    {
                        // Prompt for username
                        userName = await TerminalPrompts.CreateText("Username").ShowAsync(Context.Console);
                    }

                    // Prompt for password
                    string password = await TerminalPrompts.CreateSecret("Password").ShowAsync(Context.Console);

                    return new CredentialsPromptResult(
                        AuthenticationModes.Basic,
                        new GitCredential(userName, password));

                case AuthenticationModes.OAuth:
                    return new CredentialsPromptResult(AuthenticationModes.OAuth);

                case AuthenticationModes.None:
                    throw new ArgumentOutOfRangeException(nameof(modes),
                        @$"At least one {nameof(AuthenticationModes)} must be supplied");

                default:
                    var promptTitle = $"Select an authentication method for '{targetUri}'";
                    var prompt = TerminalPrompts.CreateSelection<AuthenticationModes>()
                        .Title(promptTitle);

                    if ((modes & AuthenticationModes.OAuth) != 0) prompt.AddChoice("OAuth", AuthenticationModes.OAuth);
                    if ((modes & AuthenticationModes.Basic) != 0) prompt.AddChoice("Username/password", AuthenticationModes.Basic);

                    AuthenticationModes choice = await prompt.ShowAsync(Context.Console);

                    if (choice == AuthenticationModes.OAuth) goto case AuthenticationModes.OAuth;
                    if (choice == AuthenticationModes.Basic) goto case AuthenticationModes.Basic;

                    throw new Exception();
            }
        }

View on GitHub (pinned to e8ce762cd0)