git-ecosystem/git-credential-manager · warning · Trace2Exception

User cancelled credential prompt

Error message

User cancelled credential prompt

What it means

GetRefreshedCredentials throws when the interactive authentication result is null or its AuthenticationMode is None, meaning the user dismissed/cancelled the credential prompt (or the UI returned nothing). Without a credential the host provider cannot continue, so it fails with a Trace2Exception after tracing the cancellation.

Solutions

  1. Retry the git operation and complete the login prompt (enter username/password or approve OAuth)
  2. For CI, pre-provision credentials (e.g. app password via GCM, cached credential, or Git's credential.store) so no prompt is needed
  3. Catch the exception in tooling and treat GIT_TERMINAL_PROMPT=0/non-interactive flows explicitly, supplying credentials non-interactively

Example fix

// before
git push  # cancelled prompt -> Trace2Exception
// after
GIT_TERMINAL_PROMPT=0 git push  # or pre-authenticate:
git config credential.helper store  # then run one interactive push
Defensive patterns

Strategy: try-catch

Validate before calling

if (Environment.UserInteractive && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DISPLAY")) || Console.IsOutputRedirected == false)
{ /* prompting is viable */ } else { /* use cached/pre-provisioned credentials */ }

Type guard

bool WasCancelled(CredentialsPromptResult r) => r is null || r.AuthenticationMode == AuthenticationModes.None;

Try / catch

try { var cred = await provider.GetCredentialAsync(input); }
catch (Trace2Exception ex) when (ex.Message == "User cancelled credential prompt") { return Result.Cancelled; }

Prevention

When it happens

Trigger: BitbucketHostProvider.GetRefreshedCredentials -> _bitbucketAuth.GetCredentialsAsync returns null or CredentialsPromptResult with mode None because the user cancelled the Bitbucket login dialog or terminal prompt.

Common situations: User pressing Cancel/Esc on the Bitbucket login window; non-interactive CI runs where the prompt auto-dismisses; TTY sessions with terminal prompts disabled.

Related errors


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

Appendix: source

Thrown at src/Atlassian.Bitbucket/BitbucketHostProvider.cs:173

            // If a refresh token is unable to be found a full OAuth authorization flow is initiated.
            ICredential refreshToken = SupportsOAuth(authModes)
                ? GetCredential(refreshTokenService, request.UserName)
                : null;

            if (refreshToken is null)
            {
                _context.Trace.WriteLine("No stored refresh token found");
                // There is no refresh token either because this is a non-2FA enabled account (where OAuth is not
                // required), or because we previously erased the RT.

                _context.Trace.WriteLine("Prompt for credentials...");

                var result = await _bitbucketAuth.GetCredentialsAsync(remoteUri, request.UserName, authModes);
                if (result is null || result.AuthenticationMode == AuthenticationModes.None)
                {
                    var message = "User cancelled credential prompt";
                    _context.Trace.WriteLine(message);
                    throw new Trace2Exception(_context.Trace2, message);
                }

                switch (result.AuthenticationMode)
                {
                    case AuthenticationModes.Basic:
                        // Return the valid credential
                        return result.Credential;

                    case AuthenticationModes.OAuth:
                        // If the user wants to use OAuth fall through to interactive auth
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(
                            $"Unexpected {nameof(AuthenticationModes)} returned from prompt");
                }

                // Fall through to the start of the interactive OAuth authentication flow

View on GitHub (pinned to e8ce762cd0)