{"record":{"id":"1c58483a7cbebf01","repo":"git-ecosystem/git-credential-manager","slug":"unknown-mode-value-in-response-responsemode","errorCode":null,"errorMessage":"Unknown mode value in response '{responseMode}'","messagePattern":"Unknown mode value in response '(.+?)'","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/Authentication/OAuthAuthentication.cs","lineNumber":172,"sourceCode":"            }\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        {\n            ThrowIfUserInteractionDisabled();\n\n            // We require a desktop session to launch the user's default web browser\n            if (!Context.SessionManager.IsDesktopSession)\n            {\n                throw new Trace2InvalidOperationException(Context.Trace2,\n                    \"Browser authentication requires a desktop session\");\n            }\n\n            var browserOptions = new OAuth2WebBrowserOptions();\n            var browser = new OAuth2SystemWebBrowser(Context.SessionManager, browserOptions);\n            var authCode = await client.GetAuthorizationCodeAsync(scopes, browser, CancellationToken.None);","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Authentication/OAuthAuthentication.cs#L154-L190","documentation":"After reading the 'mode' value from the helper response, GetAuthenticationModeViaHelperAsync switches on it and only recognizes 'browser' and 'devicecode'. Any other string raises a Trace2Exception naming the unknown value.","triggerScenarios":"The helper returns a 'mode' string other than browser/devicecode — e.g. a typo, a new mode added in a newer helper that this library doesn't know, or localized/case-mangled output (though matching is case-insensitive).","commonSituations":"Running a newer helper that supports an authentication mode the linked library predates; custom or shimmed helper scripts emitting non-standard mode values.","solutions":["Align helper and library versions so the set of supported modes matches","Fix the helper output to emit exactly 'browser' or 'devicecode'","Update GCM to a version that recognizes the new mode value","Inspect the reported responseMode value in the message to identify the offending source"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var known = new[] { \"browser\", \"devicecode\" }; if (responseMode != null && !known.Contains(responseMode.ToLowerInvariant())) throw new InvalidOperationException($\"Unknown mode '{responseMode}' from helper.\");","typeGuard":null,"tryCatchPattern":"try { mode = await oauth.GetAuthenticationModeAsync(...); } catch (Exception ex) when (ex.Message.StartsWith(\"Unknown mode value\")) { mode = OAuthAuthenticationModes.Browser; }","preventionTips":["Emit only 'browser' or 'devicecode' from custom helpers","Upgrade library and helper together so new modes are recognized","Log the raw mode value before mapping for easier diagnosis"],"tags":["oauth","helper-process","unknown-value","trace2"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T14:17:13.074Z"}