Hmbown/CodeWhale · error
Failed to run `gh api
Error message
Failed to run `gh api`: {e} What it means
The PR review submission's `gh api POST repos/{repo}/pulls/{number}/reviews` failed; the wrapped error carries gh's output so submission failures (permissions, closed PR, payload size) are diagnosable.
Solutions
- Check gh authentication (`gh auth status`) and network, then retry.
- Confirm the review payload is valid JSON and the repo/pr number are correct.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/tui/src/lib.rs:9728 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/8d9f92303b1afe4e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:9728
payload["commit_id"] = serde_json::json!(commit_id);
}
if !comments.is_empty() {
payload["comments"] = serde_json::json!(comments);
}
let mut cmd = crate::dependencies::Gh::command()
.ok_or_else(|| anyhow::anyhow!("gh not found on PATH"))?;
cmd.arg("api")
.arg("--method")
.arg("POST")
.arg(format!("repos/{repo}/pulls/{number}/reviews"))
.arg("--input")
.arg("-")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped());
let mut child = cmd
.spawn()
.map_err(|e| anyhow::anyhow!("Failed to run `gh api`: {e}"))?;
*publication = ReviewPublication::Uncertain;
if let Some(stdin) = child.stdin.as_mut() {
use std::io::Write;
stdin
.write_all(serde_json::to_string(&payload)?.as_bytes())
.map_err(|e| anyhow::anyhow!("Failed to write review payload: {e}"))?;
}
let output = child
.wait_with_output()
.map_err(|e| anyhow::anyhow!("Failed to wait for `gh api`: {e}"))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
bail!("gh api POST repos/{repo}/pulls/{number}/reviews failed: {stderr}");
}
*publication = ReviewPublication::Posted;
Ok(())
}
View on GitHub (pinned to 73e0f67d83)