{"record":{"id":"47e383c912bcd58b","repo":"gastownhall/beads","slug":"gh-pr-view-failed-s","errorCode":null,"errorMessage":"gh pr view failed: %s","messagePattern":"gh pr view failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate.go","lineNumber":1141,"sourceCode":"\t}\n\n\t// Run: gh pr view <id> --json state,title [--repo <repo>]\n\targs := []string{\"pr\", \"view\", gate.AwaitID, \"--json\", \"state,title\"}\n\tif repo != \"\" {\n\t\targs = append(args, \"--repo\", repo)\n\t}\n\tstdout, stderr, runErr := runGH(args...)\n\tif runErr != nil {\n\t\t// Check if gh CLI is not found\n\t\tif strings.Contains(string(stderr), \"command not found\") ||\n\t\t\tstrings.Contains(runErr.Error(), \"executable file not found\") {\n\t\t\treturn false, false, \"\", fmt.Errorf(\"gh CLI not installed\")\n\t\t}\n\t\t// Check if PR not found\n\t\tif strings.Contains(string(stderr), \"not found\") || strings.Contains(string(stderr), \"Could not resolve\") {\n\t\t\treturn false, true, \"pull request not found\", nil\n\t\t}\n\t\treturn false, false, \"\", fmt.Errorf(\"gh pr view failed: %s\", string(stderr))\n\t}\n\n\tvar status ghPRStatus\n\tif parseErr := json.Unmarshal(stdout, &status); parseErr != nil {\n\t\treturn false, false, \"\", fmt.Errorf(\"failed to parse gh output: %w\", parseErr)\n\t}\n\n\t// Evaluate status\n\tswitch status.State {\n\tcase \"MERGED\":\n\t\treturn true, false, fmt.Sprintf(\"PR '%s' was merged\", status.Title), nil\n\tcase \"CLOSED\":\n\t\treturn false, true, fmt.Sprintf(\"PR '%s' was closed without merging\", status.Title), nil\n\tcase \"OPEN\":\n\t\treturn false, false, fmt.Sprintf(\"PR '%s' is still open\", status.Title), nil\n\tdefault:\n\t\treturn false, false, fmt.Sprintf(\"PR '%s' state: %s\", status.Title, status.State), nil\n\t}","sourceCodeStart":1123,"sourceCodeEnd":1159,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate.go#L1123-L1159","documentation":"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.","triggerScenarios":"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.","commonSituations":"Expired GH_TOKEN, cross-repo PR the token cannot read, GitHub outage or proxy blocks, malformed repo metadata on the gate.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"gh auth status && gh pr view <number> --repo <owner/repo> --json state","typeGuard":null,"tryCatchPattern":"if _, _, _, err := checkGHPR(gate); err != nil && strings.HasPrefix(err.Error(), \"gh pr view failed:\") {\n    // read embedded stderr; retry transient network/rate-limit errors with backoff\n}","preventionTips":["Rotate GH_TOKEN before expiry","Confirm the token can read the target repo","Validate the gate's repository metadata before evaluation"],"tags":["gh-cli","pull-request","stderr"],"backgroundTag":"gh-cli-command-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}