{"record":{"id":"d7ee01af5f201d2c","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-d7ee01","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"warning","filePath":"src/Core/UI/Commands/CredentialsCommand.cs","lineNumber":53,"sourceCode":"                viewModel.Title = title;\n            }\n\n            viewModel.Description = !string.IsNullOrWhiteSpace(resource)\n                ? $\"Enter your credentials for '{resource}'\"\n                : \"Enter your credentials\";\n\n            if (!string.IsNullOrWhiteSpace(userName))\n            {\n                viewModel.UserName = userName;\n            }\n\n            viewModel.ShowProductHeader = !noLogo;\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(\n                new Dictionary<string, string>\n                {\n                    [\"username\"] = viewModel.UserName,\n                    [\"password\"] = viewModel.Password\n                }\n            );\n            return 0;\n        }\n\n        protected abstract Task ShowAsync(CredentialsViewModel viewModel, CancellationToken ct);\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":69,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/UI/Commands/CredentialsCommand.cs#L35-L69","documentation":"CredentialsCommand (the GUI credential dialog) shows a window and inspects viewModel.WindowResult after it closes. If the user dismissed/cancelled the dialog, WindowResult is false and a Trace2Exception('User cancelled dialog.') is thrown so the cancellation is recorded in Git's trace2 output rather than treated as a success with no data.","triggerScenarios":"Showing the credential dialog via ExecuteAsync (git credential fill routing to the GUI helper) and the user clicks Cancel, closes the window, or presses Escape, making WindowResult false.","commonSituations":"Users hitting Escape or the X button on the credential prompt; dialogs killed by focus/automation tools; headless-with-GUI setups where the dialog cannot be interacted with and gets dismissed.","solutions":["Complete the dialog and click OK/Submit instead of cancelling.","If cancellation is intentional, let the host handle it — git treats the helper's failure as 'no credential' and may fall back to another helper.","Avoid repeated prompts by storing credentials after first successful auth (GCM's cache/OS stores) or use a PAT in the remote URL/credential store.","In automation, prevent the dialog entirely: GCM_INTERACTIVE=never or GUI=never so a non-interactive path is used."],"exampleFix":"// before (CI invoking GUI helper)\ngit fetch   // dialog appears, auto-cancelled -> Trace2Exception\n// after\nset GCM_INTERACTIVE=never\nset GCM_GUI=never","handlingStrategy":"try-catch","validationCode":"// Don't open the dialog if the session can't interact with it:\nbool guiUsable = Environment.UserInteractive && !Console.IsOutputRedirected;","typeGuard":null,"tryCatchPattern":"try { await credentialsCommand.ExecuteAsync(...); }\ncatch (Trace2Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{ // treat as 'no credential provided', not a hard failure\n  return Result.Cancelled(); }","preventionTips":["Never invoke the GUI helper from headless/CI environments; set GCM_INTERACTIVE=never.","Communicate to users that closing the dialog cancels authentication.","Pre-provision credentials (PAT in wincredman/cache) so the dialog rarely appears.","Handle the exception in calling code as a benign cancellation signal and fall back to another credential helper."],"tags":["gui","credentials","cancelled","dialog"],"backgroundTag":"authentication-required","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"}