{"record":{"id":"07dfcd7aa7247e5e","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-credential-prompt","errorCode":null,"errorMessage":"User cancelled credential prompt","messagePattern":"User cancelled credential prompt","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"warning","filePath":"src/Atlassian.Bitbucket/BitbucketHostProvider.cs","lineNumber":173,"sourceCode":"            // If a refresh token is unable to be found a full OAuth authorization flow is initiated.\n            ICredential refreshToken = SupportsOAuth(authModes)\n                ? GetCredential(refreshTokenService, request.UserName)\n                : null;\n\n            if (refreshToken is null)\n            {\n                _context.Trace.WriteLine(\"No stored refresh token found\");\n                // There is no refresh token either because this is a non-2FA enabled account (where OAuth is not\n                // required), or because we previously erased the RT.\n\n                _context.Trace.WriteLine(\"Prompt for credentials...\");\n\n                var result = await _bitbucketAuth.GetCredentialsAsync(remoteUri, request.UserName, authModes);\n                if (result is null || result.AuthenticationMode == AuthenticationModes.None)\n                {\n                    var message = \"User cancelled credential prompt\";\n                    _context.Trace.WriteLine(message);\n                    throw new Trace2Exception(_context.Trace2, message);\n                }\n\n                switch (result.AuthenticationMode)\n                {\n                    case AuthenticationModes.Basic:\n                        // Return the valid credential\n                        return result.Credential;\n\n                    case AuthenticationModes.OAuth:\n                        // If the user wants to use OAuth fall through to interactive auth\n                        break;\n\n                    default:\n                        throw new ArgumentOutOfRangeException(\n                            $\"Unexpected {nameof(AuthenticationModes)} returned from prompt\");\n                }\n\n                // Fall through to the start of the interactive OAuth authentication flow","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Atlassian.Bitbucket/BitbucketHostProvider.cs#L155-L191","documentation":"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.","triggerScenarios":"BitbucketHostProvider.GetRefreshedCredentials -> _bitbucketAuth.GetCredentialsAsync returns null or CredentialsPromptResult with mode None because the user cancelled the Bitbucket login dialog or terminal prompt.","commonSituations":"User pressing Cancel/Esc on the Bitbucket login window; non-interactive CI runs where the prompt auto-dismisses; TTY sessions with terminal prompts disabled.","solutions":["Retry the git operation and complete the login prompt (enter username/password or approve OAuth)","For CI, pre-provision credentials (e.g. app password via GCM, cached credential, or Git's credential.store) so no prompt is needed","Catch the exception in tooling and treat GIT_TERMINAL_PROMPT=0/non-interactive flows explicitly, supplying credentials non-interactively"],"exampleFix":"// before\ngit push  # cancelled prompt -> Trace2Exception\n// after\nGIT_TERMINAL_PROMPT=0 git push  # or pre-authenticate:\ngit config credential.helper store  # then run one interactive push","handlingStrategy":"try-catch","validationCode":"if (Environment.UserInteractive && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(\"DISPLAY\")) || Console.IsOutputRedirected == false)\n{ /* prompting is viable */ } else { /* use cached/pre-provisioned credentials */ }","typeGuard":"bool WasCancelled(CredentialsPromptResult r) => r is null || r.AuthenticationMode == AuthenticationModes.None;","tryCatchPattern":"try { var cred = await provider.GetCredentialAsync(input); }\ncatch (Trace2Exception ex) when (ex.Message == \"User cancelled credential prompt\") { return Result.Cancelled; }","preventionTips":["Pre-provision credentials (app password / stored credential) for CI and non-interactive sessions","Set GIT_TERMINAL_PROMPT=0 to fail fast instead of relying on a prompt","Ensure a desktop session or working TTY exists when interactive auth is expected"],"tags":["user-cancel","authentication","prompt","bitbucket"],"backgroundTag":"authentication-required","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"}