{"record":{"id":"4f7d7f1bc80d00e0","repo":"git-ecosystem/git-credential-manager","slug":"missing-mode-in-response","errorCode":null,"errorMessage":"Missing 'mode' in response","messagePattern":"Missing 'mode' in response","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/Authentication/OAuthAuthentication.cs","lineNumber":160,"sourceCode":"            {\n                promptArgs.AppendFormat(\" --resource {0}\", QuoteCmdArg(resource));\n            }\n\n            if ((modes & OAuthAuthenticationModes.Browser) != 0)\n            {\n                promptArgs.Append(\" --browser\");\n            }\n\n            if ((modes & OAuthAuthenticationModes.DeviceCode) != 0)\n            {\n                promptArgs.Append(\" --device-code\");\n            }\n\n            IDictionary<string, string> resultDict = await InvokeHelperAsync(command, promptArgs.ToString());\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 \"browser\":\n                    return OAuthAuthenticationModes.Browser;\n\n                case \"devicecode\":\n                    return OAuthAuthenticationModes.DeviceCode;\n\n                default:\n                    throw new Trace2Exception(Context.Trace2,\n                        $\"Unknown mode value in response '{responseMode}'\");\n            }\n        }\n\n        public async Task<OAuth2TokenResult> GetTokenByBrowserAsync(OAuth2Client client, string[] scopes)\n        {","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Authentication/OAuthAuthentication.cs#L142-L178","documentation":"GetAuthenticationModeViaHelperAsync invokes the platform GCM helper process and expects a 'mode' key in the returned dictionary. A Trace2Exception is thrown when the helper's response lacks that key, indicating a malformed or unexpected helper response.","triggerScenarios":"The result dictionary returned by InvokeHelperAsync contains no 'mode' entry — e.g. helper output was not parsed into the expected key/value pairs, an old/mismatched helper version responded, or the helper returned an error payload instead of a mode selection.","commonSituations":"Version mismatch between the GCM library and an installed git-credential-helper; corrupted or non-standard stdout from the helper; running the helper on an unexpected platform where it emits different output.","solutions":["Ensure the GCM helper binary version matches the library version","Check the helper's stdout/stderr for error output that displaced the expected 'mode' response","Re-install or update Git Credential Manager","Enable Trace2 logging to capture the raw helper invocation and response"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (resultDict == null || resultDict.Count == 0) throw new InvalidOperationException(\"GCM helper returned an empty response; check helper version/output.\");","typeGuard":"bool HasMode(IDictionary<string,string> r) => r != null && r.ContainsKey(\"mode\");","tryCatchPattern":"try { mode = await oauth.GetAuthenticationModeAsync(...); } catch (Exception ex) when (ex.Message.Contains(\"Missing 'mode' in response\")) { /* reinstall/update helper or fall back to default mode */ }","preventionTips":["Keep the GCM helper binary and library versions in sync","Capture helper stdout/stderr during troubleshooting via Trace2","Avoid custom wrappers that alter the helper's output format"],"tags":["oauth","helper-process","missing-field","trace2"],"backgroundTag":"missing-required-argument","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"}