{"record":{"id":"a70f3a66c1b6dd8a","repo":"Hmbown/CodeWhale","slug":"gh-repo-view-failed-stderr","errorCode":null,"errorMessage":"gh repo view failed: {stderr}","messagePattern":"gh repo view failed: (.+?)","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":9313,"sourceCode":"\n/// Resolve the `owner/name` repository `gh` believes the current workspace\n/// belongs to. `gh api` needs an explicit repository path, unlike `gh pr`\n/// which infers it from the working directory.\nfn run_gh_repo_name() -> Result<String> {\n    let mut cmd = crate::dependencies::Gh::command()\n        .ok_or_else(|| anyhow::anyhow!(\"gh not found on PATH\"))?;\n    cmd.arg(\"repo\")\n        .arg(\"view\")\n        .arg(\"--json\")\n        .arg(\"nameWithOwner\")\n        .arg(\"--jq\")\n        .arg(\".nameWithOwner\");\n    let output = cmd\n        .output()\n        .map_err(|e| anyhow::anyhow!(\"Failed to run `gh repo view`: {e}\"))?;\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();\n        bail!(\"gh repo view failed: {stderr}\");\n    }\n    let name = String::from_utf8_lossy(&output.stdout).trim().to_string();\n    if name.is_empty() {\n        bail!(\"`gh repo view` returned an empty repository name\");\n    }\n    Ok(name)\n}\n\n/// Pick a fence long enough to wrap `replacement` without the replacement's\n/// own backticks closing the block early.\nfn suggestion_fence(replacement: &str) -> String {\n    let mut longest = 0usize;\n    let mut run = 0usize;\n    for ch in replacement.chars() {\n        if ch == '`' {\n            run += 1;\n            longest = longest.max(run);\n        } else {","sourceCodeStart":9295,"sourceCodeEnd":9331,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L9295-L9331","documentation":"The wrapper resolving the current workspace's `owner/name` via `gh repo view --json nameWithOwner` got a non-zero exit; gh's stderr is embedded. This resolution is needed because `gh api` requires an explicit repository path, unlike `gh pr`.","triggerScenarios":"Calling the repo-resolution helper from a directory that is not inside a GitHub-backed git repository (no remote gh can resolve), or when gh is unauthenticated/lacks repo access.","commonSituations":"Running `codewhale pr` outside a cloned repo or in a repo whose `origin` is not on GitHub; expired gh credentials; non-GitHub remotes (GitLab, private servers).","solutions":["Run from inside a repository with a GitHub remote (`git remote -v` to confirm)","Authenticate: `gh auth login`, then test with `gh repo view --json nameWithOwner` yourself","Pass/switch to a workspace whose origin points at the GitHub repo hosting the PR"],"exampleFix":"// before (no GitHub remote)\ngit remote -v  # -> gitlab.com/...\n// after\ngit remote set-url origin git@github.com:owner/name.git","handlingStrategy":"validation","validationCode":"gh repo view --json nameWithOwner >/dev/null 2>&1 || { echo 'not in a resolvable GitHub repo'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run codewhale pr commands from within the GitHub-hosted repo checkout","Verify the remote is GitHub (`git remote -v`), not another forge","Refresh gh credentials periodically; expired tokens fail repo resolution"],"tags":["cli","gh","git","repository-resolution"],"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-23T08:17:48.524Z"}