{"record":{"id":"a40208f2d2e54b13","repo":"Hmbown/CodeWhale","slug":"git-failed","errorCode":null,"errorMessage":"git {} failed: {}","messagePattern":"git (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/dispatch_runner.rs","lineNumber":574,"sourceCode":"fn remote_branch_exists(remote_url: &str, branch: &str) -> Result<bool> {\n    let listing =\n        git(None, &[\"ls-remote\", \"--heads\", \"--\", remote_url, branch]).unwrap_or_default();\n    Ok(listing\n        .lines()\n        .any(|line| line.contains(&format!(\"refs/heads/{branch}\"))))\n}\n\nfn git(cwd: Option<&Path>, args: &[&str]) -> Result<String> {\n    let mut command = Command::new(\"git\");\n    if let Some(cwd) = cwd {\n        command.current_dir(cwd);\n    }\n    let output = command\n        .args(args)\n        .output()\n        .context(\"failed to start git for the cloud agent branch\")?;\n    if !output.status.success() {\n        bail!(\n            \"git {} failed: {}\",\n            args.first().unwrap_or(&\"\"),\n            sanitize_error(&String::from_utf8_lossy(&output.stderr))\n        );\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).to_string())\n}\n\nfn open_pr_github(\n    slug: &str,\n    job: &CloudJob,\n    patch: &PatchReceipt,\n    title: &str,\n    body: &str,\n) -> Result<String> {\n    let body_dir = tempfile::tempdir().context(\"could not stage the PR body\")?;\n    let body_file = body_dir.path().join(\"body.md\");\n    std::fs::write(&body_file, body).context(\"could not write the PR body\")?;","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/dispatch_runner.rs#L556-L592","documentation":"The git() helper wraps every git invocation for dispatch branch preparation and push. When git exits nonzero, it bails with the subcommand name and a sanitized version of stderr, so callers see a single, secret-free git failure message.","triggerScenarios":"Any git subcommand run through git() (clone, branch apply, push, ls-remote) exits nonzero — bad ref, auth failure, network error, dirty state, etc.","commonSituations":"Missing or expired credentials for the remote, no network access, invalid branch names, missing repository at repo path, or a git hook rejecting the operation.","solutions":["Read the sanitized stderr in the error to identify the underlying git failure","Run the same git command manually to reproduce and fix (e.g. re-authenticate with gh auth login or a credential helper)","Verify the repo path exists and is a valid git working tree","Check network/VPN connectivity to the remote"],"exampleFix":"// before: push without credentials\n// authentication failed\n// after\ngh auth login\n# or\ngit config credential.helper store","handlingStrategy":"retry","validationCode":"if !repo_path.join(\".git\").exists() { /* not a git repo; fix path first */ }\n// and pre-check auth: git ls-remote <url> before long operations","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"git push failed\") => {\n        // check credentials/network, then retry with backoff\n    }\n    other => other?,\n}","preventionTips":["Authenticate gh/git credential helpers before dispatch runs","Validate the repo path is a real working tree","Check network reachability to the remote before long jobs"],"tags":["git","command","process"],"backgroundTag":"git-command-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}