The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): hermes update no longer hangs on a GitHub username prompt
Teknium10088c569e08
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex 9bbfa17693d..27de8d778ad 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -55,6 +55,22 @@ def _m():return main+def _no_prompt_git_kwargs() -> dict:+ """``subprocess.run`` kwargs for the updater's network git calls.++ GitHub answers anonymous fetches with HTTP 401 during outages (and for+ unreachable repos); git then prompts ``Username for 'https://github.com':``+ on the inherited terminal and the update sits there forever. Disable the+ prompt so the fetch fails fast into ``_classify_fetch_failure``. Only the+ *prompt* is disabled — a configured credential helper / askpass still+ runs, so a private-fork origin keeps authenticating non-interactively.+ """+ env = dict(os.environ)+ env["GIT_TERMINAL_PROMPT"] = "0"+ env["GCM_INTERACTIVE"] = "Never"+ return {"stdin": subprocess.DEVNULL, "env": env}++_UPDATE_RUNTIME_RELOAD_MODULES = ("hermes_constants","tools.environments.local",@@ -3263,6 +3279,7 @@ def _sync_fork_with_upstream(git_cmd: list[str], cwd: Path) -> bool:cwd=cwd,capture_output=True,text=True, encoding="utf-8", errors="replace",+ **_no_prompt_git_kwargs(),)return result.returncode == 0except Exception:@@ -3358,6 +3375,7 @@ def _sync_with_upstream_if_needed(cwd=cwd,capture_output=True,check=True,+ **_no_prompt_git_kwargs(),)except subprocess.CalledProcessError:print(" ✗ Failed to fetch upstream. Skipping upstream sync.")@@ -3397,6 +3415,7 @@ def _sync_with_upstream_if_needed(git_cmd + ["pull", "--ff-only", "upstream", "main"],cwd=cwd,check=True,+ **_no_prompt_git_kwargs(),)except subprocess.CalledProcessError:print(@@ -4539,7 +4558,17 @@ def _classify_fetch_failure(stderr: str) -> str:)if "Could not resolve host" in stderr or "unable to access" in stderr:return "✗ Network error — cannot reach the remote repository."- if "Authentication failed" in stderr or "could not read Username" in stderr:+ if "could not read Username" in stderr or "terminal prompts disabled" in stderr:+ # Anonymous fetch of a public repo got HTTP 401. GitHub does this+ # during outages (and for renamed/private repos) — it is not a+ # credentials problem on the user's side.+ return (+ "✗ GitHub rejected the anonymous fetch (asked for a login) — this"+ " usually means a GitHub outage; try again in a few minutes"+ " (https://www.githubstatus.com). If it persists, check"+ " `git remote -v` points at a public repo."+ )+ if "Authentication failed" in stderr:return "✗ Authentication failed — check your git credentials or SSH key."return "✗ Failed to fetch updates from origin."@@ -4646,6 +4675,7 @@ def _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):cwd=_m().PROJECT_ROOT,capture_output=True,text=True, encoding="utf-8", errors="replace",+ **_no_prompt_git_kwargs(),)if fetch_result is not None and fetch_result.returncode == 0:upstream_exists = True@@ -4658,6 +4688,7 @@ def _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):cwd=_m().PROJECT_ROOT,capture_output=True,text=True, encoding="utf-8", errors="replace",+ **_no_prompt_git_kwargs(),)upstream_exists = Falsecompare_branch = f"origin/{branch}"@@ -4669,6 +4700,7 @@ def _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):cwd=_m().PROJECT_ROOT,capture_output=True,text=True, encoding="utf-8", errors="replace",+ **_no_prompt_git_kwargs(),)upstream_exists = Falsecompare_branch = f"origin/{branch}"@@ -8591,6 +8623,7 @@ def _cmd_update_impl(args, gateway_mode: bool):cwd=_m().PROJECT_ROOT,capture_output=True,text=True, encoding="utf-8", errors="replace",+ **_no_prompt_git_kwargs(),)if fetch_result.returncode != 0:_print_fetch_failure(fetch_result.stderr)diff --git a/tests/hermes_cli/test_update_fetch_failure_classifier.py b/tests/hermes_cli/test_update_fetch_failure_classifier.pyindex f5e270c82c9..dfc6e1bcb5f 100644--- a/tests/hermes_cli/test_update_fetch_failure_classifier.py+++ b/tests/hermes_cli/test_update_fetch_failure_classifier.py@@ -51,6 +51,16 @@ class TestClassifyFetchFailure:)assert msg.startswith("✗ Network error")+ def test_username_prompt_401_reports_github_not_user_credentials(self):+ # What GitHub's HTTP 401 looks like once the terminal prompt is+ # disabled — must NOT be blamed on the user's credentials.+ msg = update_cmd._classify_fetch_failure(+ "fatal: could not read Username for 'https://github.com':"+ " terminal prompts disabled"+ )+ assert "GitHub" in msg and "outage" in msg+ assert "check your git credentials" not in msg+def test_auth_failure(self):msg = update_cmd._classify_fetch_failure("fatal: Authentication failed for 'https://github.com/x.git/'"@@ -75,3 +85,37 @@ class TestPrintFetchFailure:update_cmd._print_fetch_failure("")out = capsys.readouterr().out.strip().splitlines()assert out == ["✗ Failed to fetch updates from origin."]+++def test_update_network_git_calls_never_prompt_for_credentials():+ """Every `git fetch`/`pull`/`push` in the updater runs with prompts disabled.++ Live incident (Sep 2026): a GitHub-side 401 made `hermes update` sit on+ ``Username for 'https://github.com':`` instead of failing with a diagnosis.+ """+ import inspect+ import os+ import re+ import subprocess++ kw = update_cmd._no_prompt_git_kwargs()+ assert kw["stdin"] is subprocess.DEVNULL+ assert kw["env"]["GIT_TERMINAL_PROMPT"] == "0"+ # Only the prompt is disabled — credential helpers / askpass stay+ # configured so a private-fork origin still authenticates.+ assert "GIT_CONFIG_COUNT" not in kw["env"] or kw["env"]["GIT_CONFIG_COUNT"] == os.environ.get("GIT_CONFIG_COUNT")++ src = inspect.getsource(update_cmd)+ # Every subprocess.run(...) whose argv is a fetch/pull must spread the kwargs.+ calls = []+ for m in re.finditer(r"subprocess\.run\(", src):+ depth, i = 1, m.end()+ while depth:+ depth += {"(": 1, ")": -1}.get(src[i], 0)+ i += 1+ call = src[m.start():i]+ if re.search(r'git_cmd \+ \["(fetch|pull|push)"', call):+ calls.append(call)+ assert calls, "expected network git calls in update_cmd"+ missing = [c for c in calls if "_no_prompt_git_kwargs()" not in c]+ assert not missing, missing