{"record":{"id":"47d8f8ff8416443e","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-47d8f8","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"OperationCanceledException","httpStatus":null,"severity":"info","filePath":"src/Core/Authentication/AuthenticationBase.cs","lineNumber":122,"sourceCode":"                Context.Trace.WriteLine($\"{Constants.EnvironmentVariables.GitTerminalPrompts} is 0; GUI prompts have been disabled.\");\n                throw new Trace2InvalidOperationException(Context.Trace2, \"Cannot show prompt because GUI prompts have been disabled.\");\n            }\n        }\n\n        protected void ThrowIfTerminalPromptsDisabled()\n        {\n            if (!Context.Settings.IsTerminalPromptsEnabled)\n            {\n                Context.Trace.WriteLine($\"{Constants.EnvironmentVariables.GitTerminalPrompts} is 0; terminal prompts have been disabled.\");\n                throw new Trace2InvalidOperationException(Context.Trace2, \"Cannot prompt because terminal prompts have been disabled.\");\n            }\n        }\n        \n        protected void ThrowIfWindowCancelled(WindowViewModel viewModel)\n        {\n            if (!viewModel.WindowResult)\n            {\n                throw new OperationCanceledException(\"User cancelled dialog.\");\n            }\n        }\n        \n        protected IntPtr GetParentWindowHandle()\n        {\n            if (int.TryParse(Context.Settings.ParentWindowId, out int id))\n            {\n                return new IntPtr(id);\n            }\n\n            return IntPtr.Zero;\n        }\n\n        protected bool TryFindHelperCommand(string envar, string configName, string defaultValue, out string command, out string args)\n        {\n            command = null;\n            args = null;\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Authentication/AuthenticationBase.cs#L104-L140","documentation":"Thrown when the user closes or cancels a GUI credential dialog, indicated by the dialog's WindowViewModel.WindowResult being false. It is GCM's way of surfacing a deliberate user abort as an OperationCanceledException.","triggerScenarios":"A modal authentication window (shown by a derived AuthenticationBase implementation) is dismissed via Cancel or the X button so viewModel.WindowResult is false when ThrowIfWindowCancelled checks it.","commonSituations":"User clicks Cancel in the sign-in dialog; user closes the window without entering credentials; automation accidentally dismisses the dialog.","solutions":["Re-run the operation and complete the dialog to proceed","Make the credential dialog non-interactive by pre-supplying credentials via configuration or a credential helper","Catch OperationCanceledException in the caller and treat it as an expected user abort rather than a failure"],"exampleFix":"// before\ncatch (Exception ex) { log.Error(ex); }\n// after\ncatch (OperationCanceledException) { log.Info(\"User cancelled authentication.\"); }\ncatch (Exception ex) { log.Error(ex); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* auth flow */ }\ncatch (OperationCanceledException) { Console.Error.WriteLine(\"Authentication cancelled by user.\"); return ExitCode.Failure; }","preventionTips":["Don't leave auth dialogs unattended in automation; pre-supply credentials","Treat OperationCanceledException separately from other exceptions"],"tags":["user-cancelled","dialog","gui","operation-canceled"],"backgroundTag":"user-cancelled-operation","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"}