{"record":{"id":"3d276bb33d37fc46","repo":"git-ecosystem/git-credential-manager","slug":"unknown-mode-value-in-response-responsemode-3d276b","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/GitHub/GitHubAuthentication.cs","lineNumber":344,"sourceCode":"                case \"device\":\n                    return new AuthenticationPromptResult(AuthenticationModes.Device);\n\n                case \"basic\":\n                    if (!resultDict.TryGetValue(\"username\", out userName))\n                    {\n                        throw new Trace2Exception(Context.Trace2, \"Missing 'username' in response\");\n                    }\n\n                    if (!resultDict.TryGetValue(\"password\", out string password))\n                    {\n                        throw new Trace2Exception(Context.Trace2, \"Missing 'password' in response\");\n                    }\n\n                    return new AuthenticationPromptResult(\n                        AuthenticationModes.Basic, new GitCredential(userName, password));\n\n                default:\n                    throw new Trace2Exception(Context.Trace2,\n                        $\"Unknown mode value in response '{responseMode}'\");\n            }\n        }\n\n        public async Task<string> GetTwoFactorCodeAsync(Uri targetUri, bool isSms)\n        {\n            ThrowIfUserInteractionDisabled();\n\n            if (Context.Settings.IsGuiPromptsEnabled && Context.SessionManager.IsDesktopSession)\n            {\n                if (TryFindHelperCommand(out string command, out string args))\n                {\n                    return await GetTwoFactorCodeViaHelperAsync(isSms, args, command);\n                }\n\n                return await GetTwoFactorCodeViaUiAsync(targetUri, isSms);\n            }\n","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/GitHubAuthentication.cs#L326-L362","documentation":"After reading the 'mode' key, GetAuthenticationViaHelperAsync switches on its value against the known set: pat, browser, device, basic. Any other value means the helper and core disagree on the protocol vocabulary, so the method throws with the offending value interpolated into the message for diagnosis.","triggerScenarios":"Helper emits mode=<something unexpected> — e.g. a typo, a newer helper using an added mode the installed core doesn't know, or a corrupted/translated output value.","commonSituations":"Version skew: upgraded helper introduces a new mode string not understood by an older core; custom helper returning nonstandard mode values; manual edits or wrapper scripts altering helper output.","solutions":["Align versions: upgrade Git Credential Manager core and helper together so the mode vocabulary matches","Run the helper manually with GCM_TRACE enabled to see the exact mode value being emitted","Fix custom helper/wrapper scripts to emit only supported modes: pat, browser, device, basic","If a newer mode is genuinely needed, upgrade the core to a version whose switch statement recognizes it"],"exampleFix":"// before (custom helper)\noutput[\"mode\"] = \"web\"; // unknown to core\n// after\noutput[\"mode\"] = \"browser\"; // supported: pat | browser | device | basic","handlingStrategy":"validation","validationCode":"// Pre-validate the mode vocabulary your helper will emit\nvar allowedModes = new HashSet<string>(StringComparer.OrdinalIgnoreCase)\n    { \"pat\", \"browser\", \"device\", \"basic\" };\n// custom helper side:\nif (!allowedModes.Contains(chosenMode))\n    chosenMode = \"browser\"; // coerce to a supported value","typeGuard":"static bool IsKnownAuthMode(string mode) =>\n    mode is \"pat\" or \"browser\" or \"device\" or \"basic\";","tryCatchPattern":"try\n{\n    var result = await auth.GetAuthenticationAsync(uri, userName);\n}\ncatch (Trace2Exception ex) when (ex.Message.StartsWith(\"Unknown mode value\"))\n{\n    trace.WriteLine($\"Helper/core version skew detected: {ex.Message}; upgrade GCM.\");\n    throw;\n}","preventionTips":["Upgrade GCM core and helper together — new mode strings require a matching core","Custom helpers must only emit pat|browser|device|basic","Never post-process or translate helper output keys/values","Pin GCM versions in deployment images to avoid skew"],"tags":["github","authentication","enum","helper-contract","version-skew"],"backgroundTag":"invalid-enum-value","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"}