From ecc87a0607f7e443d157fa847966f24cb570e885 Mon Sep 17 00:00:00 2001 From: GISCE Bot Date: Thu, 30 Jul 2026 14:34:15 +0000 Subject: [PATCH] fix: handle missing gh executable --- src/github_agent_bridge/dispatch.py | 6 +++++- tests/test_modes_cli.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/github_agent_bridge/dispatch.py b/src/github_agent_bridge/dispatch.py index 666a5cb..7779a2b 100644 --- a/src/github_agent_bridge/dispatch.py +++ b/src/github_agent_bridge/dispatch.py @@ -85,7 +85,11 @@ def __init__(self, gh_bin: str = "gh", mode: RunMode = RunMode.LIVE): self.gh_bin = gh_bin def _run(self, args: list[str]) -> subprocess.CompletedProcess[str]: - return subprocess.run([self.gh_bin, *args], check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + command = [self.gh_bin, *args] + try: + return subprocess.run(command, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + except FileNotFoundError as exc: + return subprocess.CompletedProcess(command, 127, "", str(exc)) def current_login(self) -> str | None: result = self._run(["api", "user", "--jq", ".login"]) diff --git a/tests/test_modes_cli.py b/tests/test_modes_cli.py index 5b5785d..be42c19 100644 --- a/tests/test_modes_cli.py +++ b/tests/test_modes_cli.py @@ -12,6 +12,16 @@ def test_shadow_github_reaction_has_no_external_failure(): assert GitHubClient(gh_bin="definitely-not-present", mode=RunMode.SHADOW).react_eyes(make_job().context) is True +def test_live_github_command_handles_missing_gh_binary(): + client = GitHubClient(gh_bin="definitely-not-present", mode=RunMode.LIVE) + + result = client._run(["api", "user"]) + + assert result.returncode == 127 + assert result.stdout == "" + assert "definitely-not-present" in result.stderr + + class RecordingGitHubClient(GitHubClient): def __init__(self): super().__init__(mode=RunMode.LIVE)