git-ecosystem/git-credential-manager · info · Trace2Exception

User cancelled dialog.

Error message

User cancelled dialog.

What it means

Thrown by OAuthCommand.ExecuteAsync when the OAuth mode-selection dialog is closed without a selection. After ShowAsync returns, a false WindowResult means the user never picked browser/device/PAT mode, so the command throws a Trace2Exception rather than proceeding with an undefined mode. It signals intentional user cancellation.

Solutions

  1. Catch the Trace2Exception and treat it as cancellation rather than an auth failure
  2. Prefer non-interactive auth (PAT in env var or credential store, GCM_INTERACTIVE=never) so the dialog never appears
  3. Select an authentication mode and confirm the dialog to let the command proceed
  4. Pre-seed credentials so GCM skips the interactive OAuth prompt entirely

Example fix

// before
await oauthCommand.ExecuteAsync();
// after
try { await oauthCommand.ExecuteAsync(); }
catch (Trace2Exception ex) when (ex.Message == "User cancelled dialog.")
{
    Environment.ExitCode = (int)ExitCode.Cancelled;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure an interactive session before launching the OAuth mode dialog
if (Environment.GetEnvironmentVariable("GCM_INTERACTIVE") == "never" || !Environment.UserInteractive)
{
    Console.Error.WriteLine("OAuth dialog requires interactivity; configure credentials non-interactively.");
    return ExitCode.NonInteractive;
}

Try / catch

try
{
    await oauthCommand.ExecuteAsync();
}
catch (Trace2Exception ex) when (ex.Message == "User cancelled dialog.")
{
    Environment.ExitCode = (int)ExitCode.Cancelled;
}

Prevention

When it happens

Trigger: Running the OAuth authentication command; user clicks Cancel, presses Esc, or closes the mode-selection window so viewModel.WindowResult is false when ShowAsync returns.

Common situations: Unattended CI runs where the OAuth dialog appears but nobody selects a mode; users abandoning the sign-in flow; a script terminating the dialog process window.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/f922c084fd094151. Report an issue: GitHub.

Appendix: source

Thrown at src/Core/UI/Commands/OAuthCommand.cs:55

            if (!string.IsNullOrWhiteSpace(title))
            {
                viewModel.Title = title;
            }

            viewModel.Description = !string.IsNullOrWhiteSpace(resource)
                ? $"Sign in to '{resource}'"
                : "Select a sign-in option";

            viewModel.ShowBrowserLogin = browser;
            viewModel.ShowDeviceCodeLogin = deviceCode;
            viewModel.ShowProductHeader = !noLogo;

            await ShowAsync(viewModel, CancellationToken.None);

            if (!viewModel.WindowResult)
            {
                throw new Trace2Exception(Context.Trace2, "User cancelled dialog.");
            }

            var result = new Dictionary<string, string>();
            switch (viewModel.SelectedMode)
            {
                case OAuthAuthenticationModes.Browser:
                    result["mode"] = "browser";
                    break;

                case OAuthAuthenticationModes.DeviceCode:
                    result["mode"] = "devicecode";
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            WriteResult(result);

View on GitHub (pinned to e8ce762cd0)