{"record":{"id":"46a481285d4e8c9a","repo":"gastownhall/beads","slug":"gh-run-list-w-46a481","errorCode":null,"errorMessage":"gh run list: %w","messagePattern":"gh run list: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate_discover.go","lineNumber":470,"sourceCode":"\t\t\"--limit\", strconv.Itoa(limit),\n\t}\n\n\tif branch != \"\" {\n\t\targs = append(args, \"--branch\", branch)\n\t}\n\tif repo != \"\" {\n\t\targs = append(args, \"--repo\", repo)\n\t}\n\tif workflow != \"\" {\n\t\targs = append(args, \"--workflow\", workflow)\n\t}\n\n\toutput, stderr, err := runGH(args...)\n\tif err != nil {\n\t\tif len(stderr) > 0 {\n\t\t\treturn nil, fmt.Errorf(\"gh run list failed: %s\", string(stderr))\n\t\t}\n\t\treturn nil, fmt.Errorf(\"gh run list: %w\", err)\n\t}\n\n\tvar runs []GHWorkflowRun\n\tif err := json.Unmarshal(output, &runs); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse gh output: %w\", err)\n\t}\n\n\treturn runs, nil\n}\n\n// matchGateToRun finds the best matching run for a gate using heuristics.\n// If the gate has a workflow name hint in AwaitID, only runs matching that workflow are considered.\n//\n// foreignRepo must be true when runs were queried from a repo other than the\n// current one (SF1: a gate whose metadata.repo targets another repository).\n// In that case the local commit SHA and branch name are meaningless - they\n// describe the current checkout, not the foreign repo - so the commit/branch\n// heuristics are skipped entirely rather than comparing against them anyway.","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate_discover.go#L452-L488","documentation":"When the `gh run list` subprocess fails but gh produced no stderr output, bd wraps the raw exec error as \"gh run list: %w\". This is the opaque-failure branch: the process exited non-zero without any diagnostic text, typically because gh itself could not be executed rather than rejected by the API.","triggerScenarios":"runGH(args...) returns err with empty stderr: gh binary exists in PATH but is not executable, the OS fails to spawn it (ENOEXEC, EACCES), context/timeout killed the process before output, or gh crashed without writing stderr.","commonSituations":"A `gh` shim/wrapper script on PATH with a bad shebang; wrong-architecture gh binary; file permissions stripped (chmod -x); sandboxed CI blocking process execution; PATH pointing to a stub named gh that isn't the real CLI.","solutions":["Run `gh run list --limit 1` manually to reproduce the spawn failure outside bd","Check the gh binary is executable and matches your OS/arch: `file $(which gh)`","Remove or fix any `gh` wrapper/shim on PATH shadowing the real CLI (`type -a gh`)","Reinstall gh from https://cli.github.com if the binary is corrupt","Retry if the failure was a transient timeout during process startup"],"exampleFix":"// before\n$ bd gate discover\nError: gh run list: fork/exec /usr/local/bin/gh: exec format error\n// after\n$ file /usr/local/bin/gh  # wrong arch\n$ brew reinstall gh\n$ bd gate discover","handlingStrategy":"fallback","validationCode":"// preflight that gh can actually be spawned with a trivial command\nif out, err := exec.Command(\"gh\", \"--version\").Output(); err != nil || len(out) == 0 {\n  return fmt.Errorf(\"gh present on PATH but not executable; reinstall gh\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := queryGitHubRunsInRepo(branch, limit, repo, workflow); err != nil {\n  if strings.HasPrefix(err.Error(), \"gh run list:\") { // no stderr — spawn/exec failure\n    // fall back to a manual path or degraded mode; do not blind-retry\n    return fmt.Errorf(\"gh could not be executed: %w (check $(which gh))\", err)\n  }\n  return err\n}","preventionTips":["Verify `gh --version` works after installing gh, not just that the binary exists","Avoid naming scripts/wrappers `gh` on PATH that don't proxy to the real CLI","Install the correct OS/architecture gh release for the machine","After OS upgrades or permission changes, re-test gh execution before running bd discovery"],"tags":["subprocess","cli","github","environment"],"backgroundTag":"gh-cli-command-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}