{"record":{"id":"79a6262465a0c183","repo":"gastownhall/beads","slug":"gh-run-list-workflow-s-failed-s","errorCode":null,"errorMessage":"gh run list --workflow=%s failed: %s","messagePattern":"gh run list --workflow=(.+?) failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate.go","lineNumber":964,"sourceCode":"\t}\n\treturn queryGitHubRunsForWorkflowInRepoWithRunner(workflow, limit, repo, runGHCommand)\n}\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","sourceCodeStart":946,"sourceCodeEnd":982,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate.go#L946-L982","documentation":"When the `gh run list --workflow=<name>` subprocess exits non-zero and gh wrote to stderr, the function surfaces that stderr directly: \"gh run list --workflow=%s failed: <stderr>\". The message preserves gh's own diagnostics (auth failures, unknown workflow, network errors) so the user sees the real cause.","triggerScenarios":"gh is installed but `gh run list` fails: unauthenticated (`gh auth login` not run), the workflow name doesn't exist in the repo, insufficient token scopes, network failure, or wrong --repo target; reached via queryGitHubRunsForWorkflowInRepo(WithRunner) during gate/run matching.","commonSituations":"CI tokens lacking `actions: read`; typo'd workflow filename (gh expects the file name like \"ci.yml\"); expired gh auth session; corporate proxy blocking api.github.com.","solutions":["Read the stderr tail in the error; run the same command manually (`gh run list --workflow=ci.yml -R owner/repo`) to see the full output.","Authenticate: `gh auth login` or set GH_TOKEN with sufficient scopes (repo, actions: read).","Use the exact workflow file name (e.g. \"test.yml\"), not the display name, and verify with `gh workflow list -R owner/repo`.","Confirm network/proxy access to api.github.com from the environment running bd."],"exampleFix":"# before\n$ bd doctor  # gh run list --workflow=ci.yml failed: exit status 4: ... not logged in\n# after\n$ gh auth login\n$ gh auth status\n$ bd doctor","handlingStrategy":"try-catch","validationCode":"// preflight auth and workflow existence before the real call\nexec.Command(\"gh\", \"auth\", \"status\").Run()\nout, _ := exec.Command(\"gh\", \"workflow\", \"list\", \"-R\", repo, \"--json\", \"name,path\").Output()\n// verify the workflow filename exists in out before run list","typeGuard":null,"tryCatchPattern":"runs, err := queryGitHubRunsForWorkflowInRepo(\"ci.yml\", 5, \"owner/repo\")\nif err != nil {\n    var exitErr *exec.ExitError\n    if strings.Contains(err.Error(), \"gh run list --workflow=\") {\n        log.Printf(\"gh reported failure (check auth/scopes/workflow name): %v\", err)\n        return fallbackGateDecision()\n    }\n    _ = exitErr\n    return err\n}","preventionTips":["Run `gh auth login` (or set GH_TOKEN) in every environment that executes bd gate checks.","Reference workflows by file name (ci.yml), not display title.","Grant CI tokens `actions: read` scope and repo access.","Test `gh run list --workflow=X -R owner/repo` manually before wiring it into automation."],"tags":["github","cli","subprocess","authentication"],"backgroundTag":"gh-cli-command-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}