git-ecosystem/git-credential-manager · info · Trace2Exception
User cancelled dialog.
Error message
User cancelled dialog.
What it means
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.
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
Example fix
// before
var result = command.ExecuteAsync();
ProcessResult(result);
// after
try
{
var result = command.ExecuteAsync();
ProcessResult(result);
}
catch (Trace2Exception ex) when (ex.Message == "User cancelled dialog.")
{
// user cancelled; exit with a cancellation code
return ExitCode.Cancelled;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before invoking, detect non-interactive environments to avoid showing the dialog at all
bool interactive = Environment.UserInteractive &&
Environment.GetEnvironmentVariable("GCM_INTERACTIVE") != "never";
if (!interactive)
{
Console.Error.WriteLine("Skipping default-account dialog: running non-interactively.");
return;
} Try / catch
try
{
await command.ExecuteAsync();
}
catch (Trace2Exception ex) when (ex.Message == "User cancelled dialog.")
{
// treat as graceful cancellation, not failure
return ExitCode.Cancelled;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- User cancelled dialog.
- User cancelled dialog.
- User cancelled dialog.
- User cancelled dialog.
- User cancelled dialog.
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/8c57b5f56c61801a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Core/UI/Commands/DefaultAccountCommand.cs:44
this.SetHandler(ExecuteAsync, title, userName, noLogo);
}
private async Task<int> ExecuteAsync(string title, string userName, bool noLogo)
{
var viewModel = new DefaultAccountViewModel(Context.SessionManager)
{
Title = !string.IsNullOrWhiteSpace(title)
? title
: "Git Credential Manager",
UserName = userName,
ShowProductHeader = !noLogo
};
await ShowAsync(viewModel, CancellationToken.None);
if (!viewModel.WindowResult)
{
throw new Trace2Exception(Context.Trace2, "User cancelled dialog.");
}
WriteResult(
new Dictionary<string, string>
{
["use_default_account"] = viewModel.UseDefaultAccount ? "1" : "0"
}
);
return 0;
}
protected abstract Task ShowAsync(DefaultAccountViewModel viewModel, CancellationToken ct);
}
View on GitHub (pinned to e8ce762cd0)