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

helper error ( )

Error message

helper error ({exitCode}): {errorMessage}

What it means

After running a Git helper, InvokeHelperAsync parses the helper's JSON output. If the helper exits with a non-zero exit code, the exception's message from its "error" field (or "Unknown") is surfaced as a plain Exception: `helper error ({exitCode}): {errorMessage}`. This wraps helper-side failures into the caller's process.

Solutions

  1. Read the exitCode and errorMessage in the message to identify the helper's own failure and fix that root cause (config, credentials, network).
  2. If errorMessage is 'Unknown', run the helper manually with the same arguments to see its stderr output.
  3. Ensure the helper binary version matches the host tool version (reinstall/upgrade both together).
  4. Check the helper's configuration (git config) for invalid values the helper rejects.

Example fix

// before (helper exits 1 with no diagnostic)
// helper error (1): Unknown
// after: run helper directly for details
$ git credential-manager get
// then fix the reported helper-side cause
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var result = await git.InvokeHelperAsync(args, null);
}
catch (Exception ex) when (ex.Message.StartsWith("helper error ("))
{
    // parse exitCode/errorMessage from ex.Message and map to a root cause
    logger.LogError(ex, "Git helper reported failure; inspect helper configuration/version.");
}

Prevention

When it happens

Trigger: Calling InvokeHelperAsync when the helper process finishes with a non-zero exit code and its parsed result dictionary contains no successful payload — e.g. the helper reported an error key, or exited non-zero without one (errorMessage defaults to "Unknown").

Common situations: The Git helper itself failed: invalid configuration passed to it, the helper crashed, credential storage errors, or a helper version mismatch with the host's expected response contract.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


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

Appendix: source

Thrown at src/Core/Git.cs:273

                await process.StandardInput.WriteDictionaryAsync(standardInput);
                // some helpers won't continue until they see EOF
                // cf git-credential-cache
                process.StandardInput.Close();
            }

            IDictionary<string, string> resultDict = await process.StandardOutput.ReadDictionaryAsync(StringComparer.OrdinalIgnoreCase);

            await Task.Run(() => process.WaitForExit());
            int exitCode = process.ExitCode;

            if (exitCode != 0)
            {
                if (!resultDict.TryGetValue("error", out string errorMessage))
                {
                    errorMessage = "Unknown";
                }

                throw new Exception($"helper error ({exitCode}): {errorMessage}");
            }

            return resultDict;
        }

        public static GitException CreateGitException(ChildProcess git, string message, ITrace2 trace2 = null)
        {
            var gitMessage = git.StartInfo.RedirectStandardError
                ? git.StandardError.ReadToEnd()
                : null;

            if (trace2 != null)
                throw new Trace2GitException(trace2, message, git.ExitCode, gitMessage);

            throw new GitException(message, gitMessage, git.ExitCode);
        }
    }

View on GitHub (pinned to e8ce762cd0)