{"record":{"id":"037ada3ea77a6150","repo":"git-ecosystem/git-credential-manager","slug":"missing-mode-in-response-037ada","errorCode":null,"errorMessage":"Missing 'mode' in response","messagePattern":"Missing 'mode' in response","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/GitHub/GitHubAuthentication.cs","lineNumber":309,"sourceCode":"                promptArgs.Append(\" --all\");\n            }\n            else\n            {\n                if ((modes & AuthenticationModes.Basic) != 0) promptArgs.Append(\" --basic\");\n                if ((modes & AuthenticationModes.Browser) != 0) promptArgs.Append(\" --browser\");\n                if ((modes & AuthenticationModes.Device) != 0) promptArgs.Append(\" --device\");\n                if ((modes & AuthenticationModes.Pat) != 0) promptArgs.Append(\" --pat\");\n            }\n\n            if (!GitHubHostProvider.IsGitHubDotCom(targetUri))\n                promptArgs.AppendFormat(\" --enterprise-url {0}\", QuoteCmdArg(targetUri.ToString()));\n            if (!string.IsNullOrWhiteSpace(userName)) promptArgs.AppendFormat(\" --username {0}\", QuoteCmdArg(userName));\n\n            IDictionary<string, string> resultDict = await InvokeHelperAsync(command, promptArgs.ToString(), null);\n\n            if (!resultDict.TryGetValue(\"mode\", out string responseMode))\n            {\n                throw new Trace2Exception(Context.Trace2, \"Missing 'mode' in response\");\n            }\n\n            switch (responseMode.ToLowerInvariant())\n            {\n                case \"pat\":\n                    if (!resultDict.TryGetValue(\"pat\", out string pat))\n                    {\n                        throw new Trace2Exception(Context.Trace2, \"Missing 'pat' in response\");\n                    }\n\n                    return new AuthenticationPromptResult(\n                        AuthenticationModes.Pat, new GitCredential(userName, pat));\n\n                case \"browser\":\n                    return new AuthenticationPromptResult(AuthenticationModes.Browser);\n\n                case \"device\":\n                    return new AuthenticationPromptResult(AuthenticationModes.Device);","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/GitHubAuthentication.cs#L291-L327","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar result = await auth.GetAuthenticationAsync(uri, userName);\n// after\nIDictionary<string,string> result;\ntry { result = await auth.GetAuthenticationAsync(uri, userName); }\ncatch (Trace2Exception ex) when (ex.Message == \"Missing 'mode' in response\")\n{\n    // helper returned no mode: log and retry with explicit mode or reinstall helper\n    trace.WriteLine($\"Helper returned no mode: {ex.Message}\");\n    throw new HelperInvocationException(\"GitHub UI helper returned an invalid response.\", ex);\n}","handlingStrategy":"try-catch","validationCode":"// Verify the helper is installed and functional before invoking auth\nstring helperPath = Path.Combine(AppContext.BaseDirectory, \"GitHub.UI\");\nif (!File.Exists(helperPath) && !GitHubHelperPresent())\n{\n    throw new InvalidOperationException(\"GitHub UI helper is missing; reinstall Git Credential Manager.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = await auth.GetAuthenticationAsync(uri, userName);\n}\ncatch (Trace2Exception ex) when (ex.Message == \"Missing 'mode' in response\")\n{\n    trace.WriteLine(\"Helper returned malformed response; reinstalling/repairing GCM recommended.\");\n    throw;\n}","preventionTips":["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"],"tags":["github","authentication","helper-process","response-parsing"],"backgroundTag":"unexpected-response-shape","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"}