Skip to content

The agent that grows with you

fix(update): preserve fetch failure stderr context

Yuan Li1747a2e8a627
diff --git a/hermes_cli/update_cmd_git.py b/hermes_cli/update_cmd_git.py
index 3a8786f2e57..701dc8e2d24 100644
--- a/hermes_cli/update_cmd_git.py
+++ b/hermes_cli/update_cmd_git.py
@@ -530,11 +530,15 @@ def _classify_fetch_failure(stderr: str) -> str:
def _print_fetch_failure(stderr: str) -> None:
- """Print the classified diagnosis plus the first raw stderr line."""
+ """Print the classified diagnosis plus bounded raw stderr for diagnosis."""
stderr = (stderr or "").strip()
print(_classify_fetch_failure(stderr))
if stderr:
- print(f" {stderr.splitlines()[0]}")
+ lines = stderr.splitlines()
+ for line in lines[:15]:
+ print(f" {line}")
+ if len(lines) > 15:
+ print(f" ... ({len(lines) - 15} more lines omitted)")
def _probe_fork_bomb(argv: list) -> Optional[bool]:
diff --git a/tests/hermes_cli/test_update_fetch_failure_classifier.py b/tests/hermes_cli/test_update_fetch_failure_classifier.py
index a8014a90149..ff23dc9f053 100644
--- a/tests/hermes_cli/test_update_fetch_failure_classifier.py
+++ b/tests/hermes_cli/test_update_fetch_failure_classifier.py
@@ -92,13 +92,23 @@ class TestClassifyFetchFailure:
class TestPrintFetchFailure:
- def test_prints_diagnosis_and_first_raw_line(self, capsys):
+ def test_prints_diagnosis_and_bounded_raw_stderr(self, capsys):
update_cmd._print_fetch_failure(RATE_LIMIT_STDERR)
out = capsys.readouterr().out
assert "rate limiting" in out
assert "HTTP 429" in out
- # raw first stderr line preserved for diagnosability
+ # Every raw line is preserved for diagnosability.
assert "error: RPC failed" in out
+ assert "fatal: expected flush after ref listing" in out
+
+ def test_limits_raw_stderr_to_fifteen_lines(self, capsys):
+ stderr = "\n".join(f"line {i}" for i in range(20))
+ update_cmd._print_fetch_failure(stderr)
+ out = capsys.readouterr().out
+ assert " line 0" in out
+ assert " line 14" in out
+ assert " line 15" not in out
+ assert " ... (5 more lines omitted)" in out
def test_empty_stderr_prints_only_diagnosis(self, capsys):
update_cmd._print_fetch_failure("")