{"record":{"id":"71351980e2eb54aa","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-713519","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"info","filePath":"src/GitHub/UI/Commands/TwoFactorCommand.cs","lineNumber":33,"sourceCode":"        {\n            var sms = new Option<bool>(\"--sms\", \"Two-factor code was sent via SMS.\");\n            AddOption(sms);\n\n            this.SetHandler(ExecuteAsync, sms);\n        }\n\n        private async Task<int> ExecuteAsync(bool sms)\n        {\n            var viewModel = new TwoFactorViewModel(Context.SessionManager, Context.ProcessManager)\n            {\n                IsSms = sms\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            WriteResult(new Dictionary<string, string>\n            {\n                [\"code\"] = viewModel.Code\n            });\n\n            return 0;\n        }\n\n        protected abstract Task ShowAsync(TwoFactorViewModel viewModel, CancellationToken ct);\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":47,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/UI/Commands/TwoFactorCommand.cs#L15-L47","documentation":"TwoFactorCommand's ExecuteAsync shows the two-factor code dialog during GitHub authentication. If the user cancels or closes the dialog (WindowResult false), it throws this Trace2Exception because the 2FA code required to continue authentication was not provided.","triggerScenarios":"GitHub authentication with an account/app that requires two-factor authentication; the 2FA entry dialog is shown and the user closes it without entering a code.","commonSituations":"Users without their 2FA device at hand; confusion about which 2FA code (TOTP vs SMS) to enter; automation dismissing the dialog.","solutions":["Re-run the git operation and enter the current 2FA code (from your authenticator app or SMS) in the dialog.","Switch to an authentication mode that does not require legacy 2FA entry, such as browser OAuth or a PAT (which embeds 2FA at creation time).","Prefer modern flows: GitHub's OAuth/device flows handle 2FA server-side, avoiding this dialog entirely.","If prompted repeatedly, update GCM to a version that uses OAuth instead of basic-auth + 2FA prompts."],"exampleFix":"// before (basic auth triggers 2FA dialog)\ngit-credential-manager github login\n\n// after (OAuth/device flow handles 2FA server-side)\ngit-credential-manager github login --browser\n// or use a PAT created with SSO/2FA satisfied","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await twoFactorCommand.ExecuteAsync(input, output);\n}\ncatch (Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{\n    // retry with OAuth/browser flow where 2FA is handled server-side\n}","preventionTips":["Have the 2FA authenticator app ready before starting GitHub login","Prefer OAuth browser/device flows which avoid the legacy 2FA dialog","Use a PAT created after satisfying 2FA for non-interactive work","Keep GCM updated so basic-auth 2FA prompts are not used"],"tags":["github","two-factor","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"}