{"record":{"id":"1fe04adb26547611","repo":"BoundaryML/baml","slug":"gh-failed","errorCode":null,"errorMessage":"`gh {}` failed: {}","messagePattern":"`gh (.+?)` failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_size_gate/src/fetch.rs","lineNumber":205,"sourceCode":"            && path\n                .extension()\n                .is_some_and(|e| e.eq_ignore_ascii_case(\"json\"))\n        {\n            out.push(path);\n        }\n    }\n    Ok(())\n}\n\n/// Run `gh` with `args`, returning stdout. Surfaces a clear error if `gh`\n/// is missing or unauthenticated.\nfn gh(args: &[&str]) -> Result<String> {\n    let output = Command::new(\"gh\").args(args).output().context(\n        \"failed to run `gh` — install the GitHub CLI and run `gh auth login` \\\n         (or pass explicit report files instead of --branch)\",\n    )?;\n    if !output.status.success() {\n        bail!(\n            \"`gh {}` failed: {}\",\n            args.join(\" \"),\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n","sourceCodeStart":187,"sourceCodeEnd":213,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_size_gate/src/fetch.rs#L187-L213","documentation":"Wraps any non-zero exit of the GitHub CLI. The `gh` command (e.g. `gh run list`, `gh run download`, `gh api`) ran but returned failure, and its stderr is surfaced verbatim. This is how the size-gate reports authentication, rate-limit, and not-found problems from gh itself.","triggerScenarios":"Called by fetch_branch_reports and run_has_all_reports whenever a gh subprocess exits non-zero: bad auth token, network failure, nonexistent run/branch, or invalid gh arguments.","commonSituations":"gh not authenticated in CI (no GH_TOKEN); querying a branch/run that does not exist; rate limiting; gh CLI version too old for the flags used; corporate proxy blocking api.github.com.","solutions":["Read the stderr in this message — it contains gh's own diagnostic","Run `gh auth login` locally or set GH_TOKEN in CI","Verify the branch/run exists: gh run list --branch <branch>","Run the same gh command manually to reproduce and debug"],"exampleFix":"// before\ngh run download 123 --repo org/repo\n// after, with auth fixed in CI\nenv:\n  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n# or locally: gh auth login","handlingStrategy":"try-catch","validationCode":"if std::process::Command::new(\"gh\").arg(\"auth\").arg(\"status\").status().map(|s| !s.success()).unwrap_or(true) {\n    eprintln!(\"gh not authenticated; run `gh auth login` or set GH_TOKEN\");\n    std::process::exit(1);\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"`gh\") => {\n        eprintln!(\"gh invocation failed: {e}. Check `gh auth status` and that the run/branch exists.\");\n        // fall back to explicit report files\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Always set GH_TOKEN/GITHUB_TOKEN in CI before invoking size-gate --branch","Run `gh auth status` as a CI preflight step","Validate the branch/run exists with `gh run list` before downloading","Keep the gh CLI updated in CI images"],"tags":["github-cli","ci","subprocess","authentication"],"backgroundTag":"git-command-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}