{"record":{"id":"a1cf541ddc8442cf","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-a1cf54","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"info","filePath":"src/GitHub/UI/Commands/DeviceCommand.cs","lineNumber":36,"sourceCode":"            var url = new Option<string>(\"--url\", \"Verification URL.\");\n            AddOption(url);\n\n            this.SetHandler(ExecuteAsync, code, url);\n        }\n\n        private async Task<int> ExecuteAsync(string code, string url)\n        {\n            var viewModel = new DeviceCodeViewModel(Context.SessionManager)\n            {\n                UserCode = code,\n                VerificationUrl = url,\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            return 0;\n        }\n\n        protected abstract Task ShowAsync(DeviceCodeViewModel viewModel, CancellationToken ct);\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":45,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/UI/Commands/DeviceCommand.cs#L18-L45","documentation":"DeviceCommand's ExecuteAsync shows the device-code dialog (displaying the code and URL) and if the user closes the window without confirming (WindowResult false), it throws this Trace2Exception since the device flow cannot proceed without user confirmation.","triggerScenarios":"Running the device-code login command (DeviceCommand.ExecuteAsync) and cancelling/closing the device-code dialog before confirming.","commonSituations":"Users closing the 'enter this code at github.com/login/device' dialog because they changed their mind or were on a machine without browser access; headless environments where the dialog is dismissed automatically.","solutions":["Re-run the login and confirm the device-code dialog, then complete entry at https://github.com/login/device.","Use a PAT instead: 'git-credential-manager github login --pat'.","On machines without a browser, authenticate elsewhere and transfer credentials, or use GCM_INTERACTIVE=Never with stored credentials.","In scripts, catch the exception and fall back to token-based authentication."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    int result = await deviceCommand.ExecuteAsync(input, output);\n}\ncatch (Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{\n    // fall back to PAT login or abort the operation gracefully\n}","preventionTips":["Confirm the device-code dialog and enter the code before it expires","Use --pat login on machines where the dialog is likely to be dismissed","Ensure a browser is reachable so the flow can be completed","Catch the exception in scripts to avoid cascading failures"],"tags":["github","device-code","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"}