gastownhall/beads · error
gh pr view failed: %s
Error message
gh pr view failed: %s
What it means
Returned when `gh pr view <id> --json state,title` exits non-zero for reasons other than missing CLI or missing PR (cmd/bd/gate.go:1141). gh's raw stderr is embedded so the real cause (auth, permissions, network) is visible.
Source
Thrown at cmd/bd/gate.go:1141
}
// Run: gh pr view <id> --json state,title [--repo <repo>]
args := []string{"pr", "view", gate.AwaitID, "--json", "state,title"}
if repo != "" {
args = append(args, "--repo", repo)
}
stdout, stderr, runErr := runGH(args...)
if runErr != nil {
// Check if gh CLI is not found
if strings.Contains(string(stderr), "command not found") ||
strings.Contains(runErr.Error(), "executable file not found") {
return false, false, "", fmt.Errorf("gh CLI not installed")
}
// Check if PR not found
if strings.Contains(string(stderr), "not found") || strings.Contains(string(stderr), "Could not resolve") {
return false, true, "pull request not found", nil
}
return false, false, "", fmt.Errorf("gh pr view failed: %s", string(stderr))
}
var status ghPRStatus
if parseErr := json.Unmarshal(stdout, &status); parseErr != nil {
return false, false, "", fmt.Errorf("failed to parse gh output: %w", parseErr)
}
// Evaluate status
switch status.State {
case "MERGED":
return true, false, fmt.Sprintf("PR '%s' was merged", status.Title), nil
case "CLOSED":
return false, true, fmt.Sprintf("PR '%s' was closed without merging", status.Title), nil
case "OPEN":
return false, false, fmt.Sprintf("PR '%s' is still open", status.Title), nil
default:
return false, false, fmt.Sprintf("PR '%s' state: %s", status.Title, status.State), nil
}View on GitHub (pinned to 71377f2769)
Solutions
- Read the stderr embedded in the error for gh's actual message
- Run `gh pr view <number> --repo <owner/repo>` manually to reproduce
- Refresh credentials (`gh auth login`, rotate GH_TOKEN)
- Validate the gate's repository metadata slug
Defensive patterns
Strategy: retry
Validate before calling
gh auth status && gh pr view <number> --repo <owner/repo> --json state
Try / catch
if _, _, _, err := checkGHPR(gate); err != nil && strings.HasPrefix(err.Error(), "gh pr view failed:") {
// read embedded stderr; retry transient network/rate-limit errors with backoff
} Prevention
- Rotate GH_TOKEN before expiry
- Confirm the token can read the target repo
- Validate the gate's repository metadata before evaluation
When it happens
Trigger: checkGHPRWithRunner invokes `gh pr view` and it fails with stderr lacking 'command not found', 'not found', and 'Could not resolve' — auth failure, rate limit, invalid repo slug, network error.
Common situations: Expired GH_TOKEN, cross-repo PR the token cannot read, GitHub outage or proxy blocks, malformed repo metadata on the gate.
Related errors
- gh run view failed: %s
- failed to query workflow runs: %w
- no runs found for workflow '%s'
- gh CLI not installed
- failed to parse gh output: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/47e383c912bcd58b.
Report an issue: GitHub.