{"record":{"id":"aa7133a40125df2f","repo":"git-ecosystem/git-credential-manager","slug":"unknown-mode-value-in-response-responsemode-aa7133","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/GitLab/GitLabAuthentication.cs","lineNumber":256,"sourceCode":"                case \"browser\":\n                    return new AuthenticationPromptResult(AuthenticationModes.Browser);\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<OAuth2TokenResult> GetOAuthTokenViaBrowserAsync(Uri targetUri, IEnumerable<string> scopes)\n        {\n            ThrowIfUserInteractionDisabled();\n\n            var oauthClient = new GitLabOAuth2Client(HttpClient, Context.Settings, targetUri, Context.Trace2);\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 { };","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitLab/GitLabAuthentication.cs#L238-L274","documentation":"Thrown in GetAuthenticationViaHelperAsync when the 'mode' value returned by the GitLab helper is not one of the recognized values (pat, browser, basic; compared case-insensitively). This is a strict protocol enum check on the helper's response.","triggerScenarios":"Helper returns mode=token, mode=oauth, mode=PAT with trailing whitespace/newline artifacts, or any unexpected string; mode switch with unrecognized default branch hit.","commonSituations":"Hand-rolled helper scripts using a plausible-but-unsupported mode name; helpers written for GitHub's protocol reused for GitLab; shell scripts emitting CRLF line endings that corrupt the parsed value.","solutions":["Change the helper to emit exactly one of: pat, browser, or basic (lowercase, no whitespace).","Trim whitespace/CR characters from helper output before printing the mode line.","Check GCM version documentation for supported mode values if the helper was written against a different release."],"exampleFix":"// before\necho \"mode=token\"\n// after\necho \"mode=pat\"","handlingStrategy":"validation","validationCode":"case \"$MODE\" in\n  pat|browser|basic) echo \"mode=$MODE\" ;;\n  *) echo \"Invalid mode: $MODE\" >&2; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":"try {\n  var result = await auth.GetAuthenticationAsync(...);\n} catch (Trace2Exception ex) when (ex.Message.StartsWith(\"Unknown mode value in response\")) {\n  // log the raw mode value and fall back to built-in GitLab auth\n}","preventionTips":["Only use the documented values pat, browser, basic","Strip CRLF/newlines from helper output (printf instead of echo on Windows-mixed environments)","Do not copy GitHub helper mode names; GitLab's protocol differs"],"tags":["gitlab","credential-helper","invalid-enum"],"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"}