{"record":{"id":"2ac1af5f99f63848","repo":"git-ecosystem/git-credential-manager","slug":"helper-error-exitcode-errormessage-2ac1af","errorCode":null,"errorMessage":"helper error ({exitCode}): {errorMessage}","messagePattern":"helper error \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Core/Git.cs","lineNumber":273,"sourceCode":"                await process.StandardInput.WriteDictionaryAsync(standardInput);\n                // some helpers won't continue until they see EOF\n                // cf git-credential-cache\n                process.StandardInput.Close();\n            }\n\n            IDictionary<string, string> resultDict = await process.StandardOutput.ReadDictionaryAsync(StringComparer.OrdinalIgnoreCase);\n\n            await Task.Run(() => process.WaitForExit());\n            int exitCode = process.ExitCode;\n\n            if (exitCode != 0)\n            {\n                if (!resultDict.TryGetValue(\"error\", out string errorMessage))\n                {\n                    errorMessage = \"Unknown\";\n                }\n\n                throw new Exception($\"helper error ({exitCode}): {errorMessage}\");\n            }\n\n            return resultDict;\n        }\n\n        public static GitException CreateGitException(ChildProcess git, string message, ITrace2 trace2 = null)\n        {\n            var gitMessage = git.StartInfo.RedirectStandardError\n                ? git.StandardError.ReadToEnd()\n                : null;\n\n            if (trace2 != null)\n                throw new Trace2GitException(trace2, message, git.ExitCode, gitMessage);\n\n            throw new GitException(message, gitMessage, git.ExitCode);\n        }\n    }\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Git.cs#L255-L291","documentation":"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.","triggerScenarios":"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\").","commonSituations":"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.","solutions":["Read the exitCode and errorMessage in the message to identify the helper's own failure and fix that root cause (config, credentials, network).","If errorMessage is 'Unknown', run the helper manually with the same arguments to see its stderr output.","Ensure the helper binary version matches the host tool version (reinstall/upgrade both together).","Check the helper's configuration (git config) for invalid values the helper rejects."],"exampleFix":"// before (helper exits 1 with no diagnostic)\n// helper error (1): Unknown\n// after: run helper directly for details\n$ git credential-manager get\n// then fix the reported helper-side cause","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var result = await git.InvokeHelperAsync(args, null);\n}\ncatch (Exception ex) when (ex.Message.StartsWith(\"helper error (\"))\n{\n    // parse exitCode/errorMessage from ex.Message and map to a root cause\n    logger.LogError(ex, \"Git helper reported failure; inspect helper configuration/version.\");\n}","preventionTips":["Keep the helper and host tool versions in lockstep.","Run the helper standalone with the same args to capture its stderr.","Validate git config values the helper consumes before invoking it.","Treat 'Unknown' errors as a signal to reproduce manually with verbose logging."],"tags":["git-helper","exit-code","git","subprocess"],"backgroundTag":"git-command-failed","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"}