git-ecosystem/git-credential-manager · error · Trace2Exception
Missing 'mode' in response
Error message
Missing 'mode' in response
What it means
GitHubAuthentication.GetAuthenticationViaHelperAsync invokes the UI helper process and expects its response dictionary to contain a 'mode' key describing how the user authenticated (pat, browser, device, or basic). If the helper's output lacks 'mode' — an empty, malformed, or crashed helper run — the method throws this Trace2Exception because it cannot interpret the result.
Solutions
- Reinstall/repair Git Credential Manager so the UI helper matches the core binary version
- Run the helper command manually (github get-authenticator with the same args) and inspect its raw output for errors
- Check Trace2/diagnostic logs (GCM_TRACE) to see whether the helper process failed to start or returned partial output
- Verify the helper executable exists at the expected path and is executable in the current environment
Example fix
// before
var result = await auth.GetAuthenticationAsync(uri, userName);
// after
IDictionary<string,string> result;
try { result = await auth.GetAuthenticationAsync(uri, userName); }
catch (Trace2Exception ex) when (ex.Message == "Missing 'mode' in response")
{
// helper returned no mode: log and retry with explicit mode or reinstall helper
trace.WriteLine($"Helper returned no mode: {ex.Message}");
throw new HelperInvocationException("GitHub UI helper returned an invalid response.", ex);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the helper is installed and functional before invoking auth
string helperPath = Path.Combine(AppContext.BaseDirectory, "GitHub.UI");
if (!File.Exists(helperPath) && !GitHubHelperPresent())
{
throw new InvalidOperationException("GitHub UI helper is missing; reinstall Git Credential Manager.");
} Try / catch
try
{
var result = await auth.GetAuthenticationAsync(uri, userName);
}
catch (Trace2Exception ex) when (ex.Message == "Missing 'mode' in response")
{
trace.WriteLine("Helper returned malformed response; reinstalling/repairing GCM recommended.");
throw;
} Prevention
- Keep GCM core and UI helper versions in lockstep; upgrade as one unit
- Enable GCM_TRACE to capture helper output when debugging auth failures
- Run the helper command manually to verify it produces key=value output including mode
- Check that UI dependencies (.NET runtime, window manager) are present on the machine
When it happens
Trigger: The GitHub UI helper process returns a dictionary without a 'mode' entry: the helper crashed, printed nothing, an older/incompatible helper version was invoked, or its output failed to parse into the result dictionary.
Common situations: Mismatched GCM helper binaries (helper not installed or partially upgraded); helper failing silently due to missing .NET runtime or UI dependencies; corrupted install where the helper exits before writing output.
Related errors
- Missing 'code' in response
- Missing 'pat' in response
- Missing 'username' in response
- Missing 'password' in response
- Unknown mode value in response
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/037ada3ea77a6150.
Report an issue: GitHub.
Appendix: source
Thrown at src/GitHub/GitHubAuthentication.cs:309
promptArgs.Append(" --all");
}
else
{
if ((modes & AuthenticationModes.Basic) != 0) promptArgs.Append(" --basic");
if ((modes & AuthenticationModes.Browser) != 0) promptArgs.Append(" --browser");
if ((modes & AuthenticationModes.Device) != 0) promptArgs.Append(" --device");
if ((modes & AuthenticationModes.Pat) != 0) promptArgs.Append(" --pat");
}
if (!GitHubHostProvider.IsGitHubDotCom(targetUri))
promptArgs.AppendFormat(" --enterprise-url {0}", QuoteCmdArg(targetUri.ToString()));
if (!string.IsNullOrWhiteSpace(userName)) promptArgs.AppendFormat(" --username {0}", QuoteCmdArg(userName));
IDictionary<string, string> resultDict = await InvokeHelperAsync(command, promptArgs.ToString(), null);
if (!resultDict.TryGetValue("mode", out string responseMode))
{
throw new Trace2Exception(Context.Trace2, "Missing 'mode' in response");
}
switch (responseMode.ToLowerInvariant())
{
case "pat":
if (!resultDict.TryGetValue("pat", out string pat))
{
throw new Trace2Exception(Context.Trace2, "Missing 'pat' in response");
}
return new AuthenticationPromptResult(
AuthenticationModes.Pat, new GitCredential(userName, pat));
case "browser":
return new AuthenticationPromptResult(AuthenticationModes.Browser);
case "device":
return new AuthenticationPromptResult(AuthenticationModes.Device);View on GitHub (pinned to e8ce762cd0)