{"record":{"id":"6ec10b5390ad3f86","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-6ec10b","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"info","filePath":"src/GitHub/UI/Commands/CredentialsCommand.cs","lineNumber":66,"sourceCode":"                ShowTokenLogin   = all || pat,\n                ShowBasicLogin   = all || basic,\n            };\n\n            if (!GitHubHostProvider.IsGitHubDotCom(enterpriseUrl))\n            {\n                viewModel.EnterpriseUrl = enterpriseUrl;\n            }\n\n            if (!string.IsNullOrWhiteSpace(userName))\n            {\n                viewModel.UserName = userName;\n            }\n\n            await ShowAsync(viewModel, CancellationToken.None);\n\n            if (!viewModel.WindowResult)\n            {\n                throw new Trace2Exception(Context.Trace2, \"User cancelled dialog.\");\n            }\n\n            var result = new Dictionary<string, string>();\n\n            switch (viewModel.SelectedMode)\n            {\n                case AuthenticationModes.Basic:\n                    result[\"mode\"] = \"basic\";\n                    result[\"username\"] = viewModel.UserName;\n                    result[\"password\"] = viewModel.Password;\n                    break;\n\n                case AuthenticationModes.Browser:\n                    result[\"mode\"] = \"browser\";\n                    break;\n\n                case AuthenticationModes.Device:\n                    result[\"mode\"] = \"device\";","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/UI/Commands/CredentialsCommand.cs#L48-L84","documentation":"The GitHub 'credentials' UI command (choose authentication mode dialog) shows a window and expects the user to confirm. If the dialog is closed without confirming (WindowResult false), ExecuteAsync throws this Trace2Exception because no selection can be written back to the calling git process.","triggerScenarios":"Running 'git-credential-manager github' style command (CredentialsCommand.ExecuteAsync) and closing/cancelling the authentication-mode selection dialog instead of choosing an option and clicking confirm.","commonSituations":"Users pressing the X or Escape on the GitHub auth-mode dialog during a git push; GUI prompts appearing unexpectedly in semi-headless setups and being dismissed; automation closing dialogs.","solutions":["Re-run the git operation and complete the dialog (select an auth mode and click confirm) instead of cancelling.","Use a non-interactive path: provide a PAT up front or set GCM_INTERACTIVE=Never to avoid the dialog.","Pre-select the auth mode via configuration (e.g. credential.githubAuthModes) so the dialog is not required.","Handle the exception in calling code and treat it as the user declining authentication."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (Environment.UserInteractive == false)\n{\n    // don't launch the dialog; configure auth mode via credential.githubAuthModes instead\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    int result = await new CredentialsCommand(context).ExecuteAsync(input, output);\n}\ncatch (Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{\n    // treat as user declining; exit gracefully or configure auth non-interactively\n}","preventionTips":["Complete dialogs instead of closing them with X/Escape","Pre-configure GitHub auth modes so the dialog is skipped","Set GCM_INTERACTIVE=Never in non-interactive environments","In automation, avoid invoking commands that require modal confirmation"],"tags":["github","ui","dialog","user-cancellation"],"backgroundTag":"user-cancelled-dialog","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"}