{"record":{"id":"a6addc9ae5972339","repo":"unoplatform/uno","slug":"git-arguments-failed-error","errorCode":null,"errorMessage":"git {arguments} failed: {error}","messagePattern":"git (.+?) failed: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/FontFallbackPreprocessor/Program.cs","lineNumber":800,"sourceCode":"\tprivate static void RunGit(string arguments)\n\t{\n\t\tvar processStart = new ProcessStartInfo\n\t\t{\n\t\t\tFileName = \"git\",\n\t\t\tArguments = arguments,\n\t\t\tCreateNoWindow = true,\n\t\t\tUseShellExecute = false,\n\t\t\tRedirectStandardError = true,\n\t\t\tRedirectStandardOutput = true\n\t\t};\n\n\t\tusing var process = Process.Start(processStart) ?? throw new InvalidOperationException(\"Failed to start git process.\");\n\t\tprocess.WaitForExit();\n\n\t\tif (process.ExitCode != 0)\n\t\t{\n\t\t\tvar error = process.StandardError.ReadToEnd();\n\t\t\tthrow new InvalidOperationException($\"git {arguments} failed: {error}\");\n\t\t}\n\t}\n}\n","sourceCodeStart":782,"sourceCodeEnd":804,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/FontFallbackPreprocessor/Program.cs#L782-L804","documentation":"After git exits, RunGit checks the exit code; any non-zero result is surfaced by reading stderr and throwing an InvalidOperationException whose message embeds both the failing command line and git's own error text. The real cause lives inside that captured stderr string (network failure, unknown ref, auth rejection, etc.).","triggerScenarios":"git clone/fetch/checkout/sparse-checkout/reset returns non-zero: nonexistent branch or tag, private repo without credentials, network timeout or DNS failure, GitHub rate limiting, a dirty working tree blocking `reset --hard`, or a git version too old to understand `--filter=blob:none --sparse` (needs git >= 2.25).","commonSituations":"Corporate proxy or firewall blocking github.com; expired/missing GitHub auth token for a private font repo; typo'd branch name in the preprocessor config; offline build attempting a fresh clone; shallow+sparse clone flags rejected by an older git; GitHub rate limit during heavy CI.","solutions":["Read the embedded stderr in the exception message — it names the exact git failure (e.g. 'fatal: could not read Username', 'error: pathspec ... did not match').","For auth issues, provide credentials via a credential helper, GIT_ASKPASS, or a token in the remote URL for private repos.","For network issues, verify connectivity to github.com and configure HTTP_PROXY/HTTPS_PROXY if behind a proxy.","Confirm the branch/repo/sparse path in the preprocessor config actually exist on the remote.","Upgrade git to >= 2.25 if sparse/filter flags are rejected; fall back to a full shallow clone otherwise.","If the repo is already cloned and only fetch fails, retry — transient GitHub outages and rate limits resolve on backoff."],"exampleFix":"// before\nthrow new InvalidOperationException($\"git {arguments} failed: {error}\");\n\n// after — keep the message, but also surface exit code for triage\nthrow new InvalidOperationException($\"git {arguments} failed (exit {process.ExitCode}): {error.Trim()}\");","handlingStrategy":"retry","validationCode":"// Validate inputs before invoking git\nstatic void ValidateCloneTarget(string repo, string branch)\n{\n    if (string.IsNullOrWhiteSpace(repo) || !repo.Contains('/'))\n        throw new ArgumentException($\"Invalid repo spec: {repo}\");\n    if (string.IsNullOrWhiteSpace(branch))\n        throw new ArgumentException(\"Branch must be specified.\");\n}","typeGuard":null,"tryCatchPattern":"// Retry transient network failures, surface auth/branch errors immediately\nint attempts = 0;\nwhile (true)\n{\n    try { RunGit(arguments); break; }\n    catch (InvalidOperationException ex) when (IsTransient(ex.Message) && attempts++ < 3)\n    { Thread.Sleep(TimeSpan.FromSeconds(2 * attempts)); continue; }\n}","preventionTips":["Pre-clone repos in a Docker layer so builds don't hit the network every run.","Configure a credential helper / token for private repos rather than relying on interactive prompts.","Pin and validate the branch/tag name from config before invoking git.","Log the exact `git` command and exit code on failure for fast triage.","For CI, cache the cloned repo between runs and only fetch increments."],"tags":["git","network","ci","build","authentication"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}