Hmbown/CodeWhale · error

Failed to run `gh repo view

Error message

Failed to run `gh repo view`: {e}

What it means

run_gh_repo_name wraps a failing `gh repo view --json nameWithOwner`; repository resolution for `gh api` calls failed — not a repo, no auth, or gh could not infer owner/name from the working directory.

Solutions

  1. Check the io error detail in {e}; typical causes are gh not authenticated or no network.
  2. Run `gh repo view` manually in the workspace to confirm gh can infer the repository.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/tui/src/lib.rs:9310 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/1793e5acecf83852. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:9310

    }
    Ok(())
}

/// Resolve the `owner/name` repository `gh` believes the current workspace
/// belongs to. `gh api` needs an explicit repository path, unlike `gh pr`
/// which infers it from the working directory.
fn run_gh_repo_name() -> Result<String> {
    let mut cmd = crate::dependencies::Gh::command()
        .ok_or_else(|| anyhow::anyhow!("gh not found on PATH"))?;
    cmd.arg("repo")
        .arg("view")
        .arg("--json")
        .arg("nameWithOwner")
        .arg("--jq")
        .arg(".nameWithOwner");
    let output = cmd
        .output()
        .map_err(|e| anyhow::anyhow!("Failed to run `gh repo view`: {e}"))?;
    if !output.status.success() {
        let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
        bail!("gh repo view failed: {stderr}");
    }
    let name = String::from_utf8_lossy(&output.stdout).trim().to_string();
    if name.is_empty() {
        bail!("`gh repo view` returned an empty repository name");
    }
    Ok(name)
}

/// Pick a fence long enough to wrap `replacement` without the replacement's
/// own backticks closing the block early.
fn suggestion_fence(replacement: &str) -> String {
    let mut longest = 0usize;
    let mut run = 0usize;
    for ch in replacement.chars() {
        if ch == '`' {

View on GitHub (pinned to 73e0f67d83)