{"record":{"id":"039fba25e1e2e9de","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-039fba","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"info","filePath":"src/GitHub/UI/Commands/SelectAccountCommand.cs","lineNumber":41,"sourceCode":"            this.SetHandler(ExecuteAsync, url, noHelp);\n        }\n\n        private async Task<int> ExecuteAsync(string enterpriseUrl, bool noHelp)\n        {\n            // Read accounts from standard input\n            IList<string> accounts = ReadAccounts();\n\n            var viewModel = new SelectAccountViewModel(Context.SessionManager, accounts)\n            {\n                EnterpriseUrl = enterpriseUrl,\n                ShowHelpLink = !noHelp\n            };\n\n            await ShowAsync(viewModel, CancellationToken.None);\n\n            if (!viewModel.WindowResult)\n            {\n                throw new Exception(\"User cancelled dialog.\");\n            }\n\n            WriteResult(new Dictionary<string, string>\n            {\n                [\"account\"] = viewModel.SelectedAccount?.UserName\n            });\n\n            return 0;\n        }\n\n        private IList<string> ReadAccounts()\n        {\n            var accounts = new List<string>();\n\n            string line;\n            while (!string.IsNullOrWhiteSpace(line = Context.Streams.In.ReadLine()))\n            {\n                accounts.Add(line.Trim());","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/UI/Commands/SelectAccountCommand.cs#L23-L59","documentation":"SelectAccountCommand's ExecuteAsync shows an account-selection dialog after listing stored GitHub accounts. If the window is closed without picking an account (WindowResult false), it throws a plain Exception with this message because no account can be written to the result.","triggerScenarios":"Running the select-account command when multiple GitHub accounts are stored and the user cancels or closes the account picker dialog without selecting one.","commonSituations":"Users with several GitHub accounts dismissing the picker; automation that cannot render the dialog; users wanting to add a new account but cancelling instead.","solutions":["Re-run the command and explicitly select an account, then confirm the dialog.","Remove unwanted stored accounts ('git-credential-manager github logout') so the picker is not needed.","Specify the account/username up front in the git URL (e.g. https://username@github.com/owner/repo.git) to bypass the picker.","Catch the exception in tooling and treat it as 'no account chosen'."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var accounts = run(\"git-credential-manager github list\");\nif (accounts.Split('\\n', StringSplitOptions.RemoveEmptyEntries).Length > 1)\n{\n    // multiple accounts: embed the desired user in the remote URL to skip the picker\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await selectAccountCommand.ExecuteAsync(input, output);\n}\ncatch (Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{\n    // no account chosen; fall back to username-in-URL or re-prompt\n}","preventionTips":["Embed the username in the remote URL (https://user@github.com/...) to avoid the account picker","Log out unused GitHub accounts to keep a single stored account","Complete the picker dialog rather than closing it","In scripts, catch the exception and prompt for the account explicitly"],"tags":["github","account-selection","ui","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"}