{"record":{"id":"7a07b00e1d922d5a","repo":"git-ecosystem/git-credential-manager","slug":"missing-password-in-response-7a07b0","errorCode":null,"errorMessage":"Missing 'password' in response","messagePattern":"Missing 'password' in response","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/GitHub/GitHubAuthentication.cs","lineNumber":337,"sourceCode":"\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);\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))","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/GitHub/GitHubAuthentication.cs#L319-L355","documentation":"For response mode 'basic', the helper must return both 'username' and 'password'. This exception is thrown when the 'password' key is absent after a username was successfully read. Without the password no GitCredential can be constructed, so the method aborts.","triggerScenarios":"Helper returns mode=basic with a username but no 'password' entry: the password field was skipped, a custom helper omitted it, or the response dictionary was built incompletely.","commonSituations":"User submits the basic auth dialog with an empty password; custom helper implementations that only emit username; password output lost due to encoding/parsing problems in the helper pipeline.","solutions":["Retry authentication and ensure both username and password fields are completed","Update GCM and its helper to matching versions","Switch to browser/device/PAT authentication modes that do not use the basic password prompt","In custom helpers, always emit mode=basic with both username and password keys"],"exampleFix":"// before\noutput[\"mode\"] = \"basic\";\noutput[\"username\"] = username; // password missing\n// after\noutput[\"mode\"] = \"basic\";\noutput[\"username\"] = username;\noutput[\"password\"] = password ?? throw new InvalidOperationException(\"Password must be supplied for basic auth.\");","handlingStrategy":"try-catch","validationCode":"// Avoid basic-auth path in automation where empty passwords are common\nstring password = Environment.GetEnvironmentVariable(\"GITHUB_PASSWORD\");\nif (string.IsNullOrEmpty(password))\n{\n    Console.Error.WriteLine(\"No stored password; use PAT or browser auth instead of basic mode.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = await auth.GetAuthenticationAsync(uri, userName);\n}\ncatch (Trace2Exception ex) when (ex.Message == \"Missing 'password' in response\")\n{\n    trace.WriteLine(\"Helper returned basic mode without password; retry or switch auth mode.\");\n    throw;\n}","preventionTips":["Never submit the basic dialog with an empty password; cancel instead so cancellation is explicit","Use PAT or OAuth browser flow where passwords aren't needed","Match helper/core versions to keep the response contract intact","In custom helpers, guard against null/empty password before emitting output"],"tags":["github","authentication","basic-auth","helper-contract"],"backgroundTag":"response-missing-required-field","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"}