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

Missing username in response

Error message

Missing username in response

What it means

When credentials are collected by the external UI helper process (GetCredentialsViaHelperAsync), the helper's JSON output must contain a 'username' key. If it is absent the library cannot build a GitCredential and throws Trace2Exception 'Missing username in response'. This usually indicates a broken or non-GCM UI helper binary.

Solutions

  1. Reinstall/upgrade Git Credential Manager so the Bitbucket UI helper binary matches the current version
  2. Remove stale duplicate helper binaries from PATH
  3. Run with GCM_TRACE/Trace2 enabled to capture the helper's raw output and diagnose the partial response

Example fix

// before
// helper returns {"password":"..."} (no username)
// after
// helper must return {"username":"user","password":"..."}; reinstall matching GCM helper
Defensive patterns

Strategy: try-catch

Validate before calling

var proc = FindHelperBinary();
if (proc == null || !File.Exists(proc)) throw new InvalidOperationException("UI helper missing/stale");

Type guard

bool HasUsername(Dictionary<string,string> o) => o.TryGetValue("username", out var u) && !string.IsNullOrEmpty(u);

Try / catch

try { await auth.GetCredentialsAsync(uri, user, modes); }
catch (Trace2Exception ex) { trace.Error(ex); return null; } // fall back to terminal prompt

Prevention

When it happens

Trigger: GetCredentialsAsync -> GetCredentialsViaHelperAsync parses the helper's dictionary output and output.TryGetValue("username", out userName) returns false — e.g. helper exited partially or returned only some keys.

Common situations: Stale/mismatched atlassian-bitbucket-ui-helper.exe on PATH from a different GCM version; helper crashed mid-run and emitted partial output; custom or third-party UI helpers.

Related errors


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

Appendix: source

Thrown at src/Atlassian.Bitbucket/BitbucketAuthentication.cs:237

            }

            if ((modes & AuthenticationModes.OAuth) != 0)
            {
                promptArgs.Append(" --show-oauth");
            }

            IDictionary<string, string> output = await InvokeHelperAsync(helperCommand, promptArgs.ToString());

            if (output.TryGetValue("mode", out string mode) &&
                StringComparer.OrdinalIgnoreCase.Equals(mode, "oauth"))
            {
                return new CredentialsPromptResult(AuthenticationModes.OAuth);
            }
            else
            {
                if (!output.TryGetValue("username", out userName))
                {
                    throw new Trace2Exception(Context.Trace2, "Missing username in response");
                }

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

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

        public async Task<OAuth2TokenResult> CreateOAuthCredentialsAsync(GitRequest request)
        {
            ThrowIfUserInteractionDisabled();

            var browserOptions = new OAuth2WebBrowserOptions

View on GitHub (pinned to e8ce762cd0)