git-ecosystem/git-credential-manager · error · Trace2Exception

Missing 'password' in response

Error message

Missing 'password' in response

What it means

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.

Solutions

  1. Retry authentication and ensure both username and password fields are completed
  2. Update GCM and its helper to matching versions
  3. Switch to browser/device/PAT authentication modes that do not use the basic password prompt
  4. In custom helpers, always emit mode=basic with both username and password keys

Example fix

// before
output["mode"] = "basic";
output["username"] = username; // password missing
// after
output["mode"] = "basic";
output["username"] = username;
output["password"] = password ?? throw new InvalidOperationException("Password must be supplied for basic auth.");
Defensive patterns

Strategy: try-catch

Validate before calling

// Avoid basic-auth path in automation where empty passwords are common
string password = Environment.GetEnvironmentVariable("GITHUB_PASSWORD");
if (string.IsNullOrEmpty(password))
{
    Console.Error.WriteLine("No stored password; use PAT or browser auth instead of basic mode.");
    return;
}

Try / catch

try
{
    var result = await auth.GetAuthenticationAsync(uri, userName);
}
catch (Trace2Exception ex) when (ex.Message == "Missing 'password' in response")
{
    trace.WriteLine("Helper returned basic mode without password; retry or switch auth mode.");
    throw;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/7a07b00e1d922d5a. Report an issue: GitHub.

Appendix: source

Thrown at src/GitHub/GitHubAuthentication.cs:337

                    return new AuthenticationPromptResult(
                        AuthenticationModes.Pat, new GitCredential(userName, pat));

                case "browser":
                    return new AuthenticationPromptResult(AuthenticationModes.Browser);

                case "device":
                    return new AuthenticationPromptResult(AuthenticationModes.Device);

                case "basic":
                    if (!resultDict.TryGetValue("username", out userName))
                    {
                        throw new Trace2Exception(Context.Trace2, "Missing 'username' in response");
                    }

                    if (!resultDict.TryGetValue("password", out string password))
                    {
                        throw new Trace2Exception(Context.Trace2, "Missing 'password' in response");
                    }

                    return new AuthenticationPromptResult(
                        AuthenticationModes.Basic, new GitCredential(userName, password));

                default:
                    throw new Trace2Exception(Context.Trace2,
                        $"Unknown mode value in response '{responseMode}'");
            }
        }

        public async Task<string> GetTwoFactorCodeAsync(Uri targetUri, bool isSms)
        {
            ThrowIfUserInteractionDisabled();

            if (Context.Settings.IsGuiPromptsEnabled && Context.SessionManager.IsDesktopSession)
            {
                if (TryFindHelperCommand(out string command, out string args))

View on GitHub (pinned to e8ce762cd0)