Hmbown/CodeWhale · error

PR input command failed

Error message

PR input command failed: {}

What it means

After the size checks pass, run_command verifies the child process exit status. Any non-zero exit makes it bail with 'PR input command failed: {stderr}', embedding the trimmed stderr text so the caller can see why git/gh failed.

Solutions

  1. Read the embedded stderr in the error message to identify the underlying git/gh failure
  2. Run the same command manually to reproduce: confirm refs exist with `git rev-parse <ref>` / `gh pr view <id>`
  3. Authenticate: run `gh auth login` or configure git credentials for the remote
  4. Ensure the PR ref is fetched locally (`git fetch origin pull/<id>/head`) before reviewing

Example fix

// before
review_pr("origin/pr-9999") // ref never fetched
// after
git(["fetch", "origin", "pull/9999/head"])?;
review_pr("FETCH_HEAD")
Defensive patterns

Strategy: try-catch

Validate before calling

let ok = std::process::Command::new("git").args([&"rev-parse", ref]).output().map(|o| o.status.success()).unwrap_or(false);

Try / catch

match result { Err(e) if e.to_string().contains("PR input command failed") => { log stderr embedded in e; check refs/auth } , Ok(v) => v }

Prevention

When it happens

Trigger: Any git/gh invocation run through run_command (fetch_diff, fetch_view, context_blob, git()) exits non-zero — e.g. bad ref, missing remote, authentication failure, nonexistent PR branch.

Common situations: Reviewing a PR whose branch was deleted or not fetched locally; gh/git not authenticated; wrong repository remote; typo'd ref or revision passed to fetch_diff/fetch_view.

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 Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/94c16daf4f75a0e9. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/review_pr.rs:509

        None => {
            let _ = child.kill();
            let _ = child.wait();
            bail!("PR input command timed out; no partial output was accepted");
        }
    };
    let stdout = stdout
        .join()
        .map_err(|_| anyhow::anyhow!("PR stdout reader failed"))??;
    let stderr = stderr
        .join()
        .map_err(|_| anyhow::anyhow!("PR stderr reader failed"))??;
    if stdout.len() > MAX_OUTPUT_BYTES || stderr.len() > 64 * 1024 {
        bail!(
            "PR input exceeds the bounded capture limit (8 MiB diff); no partial output was accepted"
        );
    }
    if !status.success() {
        bail!(
            "PR input command failed: {}",
            String::from_utf8_lossy(&stderr).trim()
        );
    }
    String::from_utf8(stdout).context("PR diff is not valid UTF-8; no lossy review is accepted")
}

#[cfg(test)]
mod tests {
    use super::*;

    fn view(files: usize) -> GhPullRequest {
        GhPullRequest {
            title: "Fixture".into(),
            body: String::new(),
            base: "main".into(),
            head: "feature".into(),
            url: "https://github.com/example/repo/pull/6002".into(),

View on GitHub (pinned to 73e0f67d83)