{"record":{"id":"8c57b5f56c61801a","repo":"git-ecosystem/git-credential-manager","slug":"user-cancelled-dialog-8c57b5","errorCode":null,"errorMessage":"User cancelled dialog.","messagePattern":"User cancelled dialog\\.","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"info","filePath":"src/Core/UI/Commands/DefaultAccountCommand.cs","lineNumber":44,"sourceCode":"        this.SetHandler(ExecuteAsync, title, userName, noLogo);\n    }\n\n    private async Task<int> ExecuteAsync(string title, string userName, bool noLogo)\n    {\n        var viewModel = new DefaultAccountViewModel(Context.SessionManager)\n        {\n            Title = !string.IsNullOrWhiteSpace(title)\n                ? title\n                : \"Git Credential Manager\",\n            UserName = userName,\n            ShowProductHeader = !noLogo\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(\n            new Dictionary<string, string>\n            {\n                [\"use_default_account\"] = viewModel.UseDefaultAccount ? \"1\" : \"0\"\n            }\n        );\n\n        return 0;\n    }\n\n    protected abstract Task ShowAsync(DefaultAccountViewModel viewModel, CancellationToken ct);\n}\n","sourceCodeStart":26,"sourceCodeEnd":59,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/UI/Commands/DefaultAccountCommand.cs#L26-L59","documentation":"This error is thrown by the DefaultAccountCommand when the user closes the account-selection dialog without confirming a choice (WindowResult is false). The command cannot produce a 'use_default_account' result without user consent, so it aborts with a Trace2Exception for tracing purposes. It is an intentional cancellation signal, not a bug in the library.","triggerScenarios":"Running the default-account UI command (e.g. 'git-credential-manager github' default-account flow) and the user presses Cancel, closes the window, or dismisses the dialog via Esc so viewModel.WindowResult stays false after ShowAsync.","commonSituations":"Developers scripting GCM in CI or automation encounter this when the dialog appears but no user is present to confirm; end users simply cancel the dialog; the window is closed by the OS or a timeout without submitting.","solutions":["Treat the exception as user cancellation: catch it in the caller and exit gracefully without retrying","When running non-interactively, set GCM_INTERACTIVE=never or use the appropriate non-interactive configuration so the dialog is never shown","Complete the dialog and confirm a choice instead of closing it","Call the command with explicit arguments (e.g. supply the account selection) so the dialog can be skipped"],"exampleFix":"// before\nvar result = command.ExecuteAsync();\nProcessResult(result);\n// after\ntry\n{\n    var result = command.ExecuteAsync();\n    ProcessResult(result);\n}\ncatch (Trace2Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{\n    // user cancelled; exit with a cancellation code\n    return ExitCode.Cancelled;\n}","handlingStrategy":"try-catch","validationCode":"// Before invoking, detect non-interactive environments to avoid showing the dialog at all\nbool interactive = Environment.UserInteractive &&\n    Environment.GetEnvironmentVariable(\"GCM_INTERACTIVE\") != \"never\";\nif (!interactive)\n{\n    Console.Error.WriteLine(\"Skipping default-account dialog: running non-interactively.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await command.ExecuteAsync();\n}\ncatch (Trace2Exception ex) when (ex.Message == \"User cancelled dialog.\")\n{\n    // treat as graceful cancellation, not failure\n    return ExitCode.Cancelled;\n}","preventionTips":["Set GCM_INTERACTIVE=never (or the provider's non-interactive flag) in CI/headless environments so dialogs never appear","Catch Trace2Exception with message 'User cancelled dialog.' explicitly and map it to a cancelled exit code","Supply credentials non-interactively (env vars, credential store) so the dialog is skipped","Educate users that closing the window equals cancelling the operation"],"tags":["ui","dialog","cancellation","user-interaction"],"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"}