{"record":{"id":"74809d3725bf5267","repo":"gastownhall/beads","slug":"gh-run-list-w","errorCode":null,"errorMessage":"gh run list: %w","messagePattern":"gh run list: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate.go","lineNumber":966,"sourceCode":"}\n\nfunc queryGitHubRunsForWorkflowInRepoWithRunner(workflow string, limit int, repo string, runGH ghCommandRunner) ([]GHWorkflowRun, error) {\n\targs := []string{\n\t\t\"run\", \"list\",\n\t\t\"--workflow\", workflow,\n\t\t\"--json\", \"databaseId,name,status,conclusion,createdAt,workflowName\",\n\t\t\"--limit\", fmt.Sprintf(\"%d\", limit),\n\t}\n\tif repo != \"\" {\n\t\targs = append(args, \"--repo\", repo)\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 --workflow=%s failed: %s\", workflow, 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// discoverRunIDByWorkflowName queries GitHub for the most recent run of a workflow.\n// Returns (runID, error). This is ZFC-compliant: \"most recent run\" is deterministic.\nfunc discoverRunIDByWorkflowName(workflowHint string) (string, error) {\n\treturn discoverRunIDByWorkflowNameInRepo(workflowHint, \"\")\n}\n\nfunc discoverRunIDByWorkflowNameInRepo(workflowHint, repo string) (string, error) {\n\treturn discoverRunIDByWorkflowNameInRepoWithRunner(workflowHint, repo, runGHCommand)","sourceCodeStart":948,"sourceCodeEnd":984,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate.go#L948-L984","documentation":"Fallback branch of the same gh subprocess call: if `gh run list` fails but produced NO stderr output, the raw exec error is wrapped as \"gh run list: %w\". Typically this is a process-level failure (gh not executable, killed by signal, exec format/permission problem) rather than a gh-reported API error.","triggerScenarios":"runGH invoked but the process fails without writing stderr — e.g. permission denied on the gh binary, SIGKILL/OOM, a test runner replacing ghCommandRunner and returning an error with empty stderr, or stdout/stderr pipe misconfiguration.","commonSituations":"Non-executable or corrupted gh binary after a partial upgrade; container seccomp/sandbox blocking exec; custom ghCommandRunner implementations in tests returning bare errors.","solutions":["Check the wrapped error text (it follows \"gh run list:\") for the OS-level cause (permission denied, signal, etc.).","Verify the gh binary: `ls -l $(which gh)` and `gh --version`; reinstall if corrupted or chmod +x if not executable.","If a custom runner is injected (tests/tools), make it return descriptive stderr so future failures surface the gh message instead.","Re-run the failing bd command after fixing the environment."],"exampleFix":"// before (custom runner)\nreturn nil, nil, errors.New(\"simulated\")\n// after\nreturn nil, []byte(\"injected failure\"), errors.New(\"simulated gh failure\")","handlingStrategy":"try-catch","validationCode":"// verify gh binary health before calls\nif out, err := exec.Command(\"gh\", \"--version\").Output(); err != nil || len(out) == 0 {\n    return errors.New(\"gh binary is not executable or broken\")\n}","typeGuard":null,"tryCatchPattern":"runs, err := queryGitHubRunsForWorkflowInRepo(\"ci.yml\", 5, repo)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"gh run list: \") {\n        return fmt.Errorf(\"gh process-level failure (binary/permissions/signal): %w\", err)\n    }\n    return err\n}","preventionTips":["Keep gh updated via a package manager so binaries are never half-written.","Check file permissions/executability after manual gh installs.","When injecting custom ghCommandRunners in tests, always return non-empty stderr for failures so errors stay diagnosable."],"tags":["github","cli","subprocess"],"backgroundTag":"gh-cli-command-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}