From a5147331ea1924403e1968a476e1933069e5990c Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Fri, 24 Jul 2026 10:19:03 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20repair=20sweep=20fallout=20=E2=80=94=20d?= =?UTF-8?q?uplicate=20encoding=20kwargs,=20non-subprocess=20call=20sites,?= =?UTF-8?q?=20kwarg-snapshot=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Strip the salvaged commit's inline encoding kwargs where main had since gained its own (process_registry, local env, cua doctor, gateway, commands, gateway_windows — the latter keeps its locale-aware _schtasks_encoding() from #38186) - Revert encoding kwargs mistakenly applied to non-subprocess APIs (exa get_contents, tempfile.mkstemp in webhook.py) - Guard the ddgs worker Popen (new on main since #55339) - Update two kwarg-snapshot test assertions for the new kwargs --- hermes_cli/commands.py | 2 +- hermes_cli/gateway.py | 4 ++-- hermes_cli/gateway_windows.py | 2 +- hermes_cli/webhook.py | 2 +- plugins/web/ddgs/provider.py | 2 ++ plugins/web/exa/provider.py | 2 +- tests/hermes_cli/test_update_autostash.py | 7 ++++--- tests/tools/test_docker_environment.py | 2 ++ tools/computer_use/doctor.py | 2 +- tools/environments/local.py | 2 +- 10 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hermes_cli/commands.py b/hermes_cli/commands.py index d78bbbf5faea..bad2250da009 100644 --- a/hermes_cli/commands.py +++ b/hermes_cli/commands.py @@ -1669,7 +1669,7 @@ class SlashCommandCompleter(Completer): continue try: proc = subprocess.run( - cmd, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=2, + cmd, capture_output=True, text=True, timeout=2, cwd=cwd, encoding="utf-8", errors="replace", ) if proc.returncode == 0 and proc.stdout and proc.stdout.strip(): diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index 29cc802f861e..2a7c2f3de35a 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -421,7 +421,7 @@ def _scan_gateway_pids( "/FORMAT:LIST", ], capture_output=True, - text=True, encoding='utf-8', errors='replace', + text=True, encoding="utf-8", errors="ignore", timeout=10, @@ -447,7 +447,7 @@ def _scan_gateway_pids( result = subprocess.run( [powershell, "-NoProfile", "-Command", ps_cmd], capture_output=True, - text=True, encoding='utf-8', errors='replace', + text=True, encoding="utf-8", errors="ignore", timeout=15, diff --git a/hermes_cli/gateway_windows.py b/hermes_cli/gateway_windows.py index 0a0b2041a671..a55200a15dff 100644 --- a/hermes_cli/gateway_windows.py +++ b/hermes_cli/gateway_windows.py @@ -160,7 +160,7 @@ def _exec_schtasks(args: list[str]) -> tuple[int, str, str]: proc = subprocess.run( [schtasks, *args], capture_output=True, - text=True, encoding='utf-8', errors='replace', + text=True, # Localized Windows emits schtasks output in the console code page, # not UTF-8. Decode with the locale encoding and replace undecodable # bytes so a non-UTF-8 status line never surfaces a UnicodeDecodeError diff --git a/hermes_cli/webhook.py b/hermes_cli/webhook.py index 823347f6e1ac..9b9de6cd5a6c 100644 --- a/hermes_cli/webhook.py +++ b/hermes_cli/webhook.py @@ -59,7 +59,7 @@ def _save_subscriptions(subs: Dict[str, dict]) -> None: prefix=f".{path.name}.", suffix=".tmp", dir=path.parent, - text=True, encoding='utf-8', errors='replace', + text=True, ) tmp_path = Path(tmp_name) try: diff --git a/plugins/web/ddgs/provider.py b/plugins/web/ddgs/provider.py index 44a3aca6c8c3..824f3edba6d6 100644 --- a/plugins/web/ddgs/provider.py +++ b/plugins/web/ddgs/provider.py @@ -193,6 +193,8 @@ def _run_ddgs_search_bounded(query: str, safe_limit: int) -> list[dict[str, Any] stderr=subprocess.DEVNULL, env=env, text=True, + encoding="utf-8", + errors="replace", **extra_kwargs, ) _last_worker_proc = proc diff --git a/plugins/web/exa/provider.py b/plugins/web/exa/provider.py index 60e73a3f3578..17ce665dc18a 100644 --- a/plugins/web/exa/provider.py +++ b/plugins/web/exa/provider.py @@ -170,7 +170,7 @@ class ExaWebSearchProvider(WebSearchProvider): ] logger.info("Exa extract: %d URL(s)", len(urls)) - response = _get_exa_client().get_contents(urls, text=True, encoding='utf-8', errors='replace') + response = _get_exa_client().get_contents(urls, text=True) results: List[Dict[str, Any]] = [] for result in response.results or []: diff --git a/tests/hermes_cli/test_update_autostash.py b/tests/hermes_cli/test_update_autostash.py index 5ffdb519bfda..c112b83d373e 100644 --- a/tests/hermes_cli/test_update_autostash.py +++ b/tests/hermes_cli/test_update_autostash.py @@ -206,9 +206,10 @@ def test_restore_stashed_changes_keeps_going_when_stash_entry_cannot_be_resolved restored = hermes_main._restore_stashed_changes(["git"], tmp_path, "abc123", prompt_user=False) assert restored is True - assert calls[0] == (["git", "stash", "apply", "abc123"], {"cwd": tmp_path, "capture_output": True, "text": True}) - assert calls[1] == (["git", "diff", "--name-only", "--diff-filter=U"], {"cwd": tmp_path, "capture_output": True, "text": True}) - assert calls[2] == (["git", "stash", "list", "--format=%gd %H"], {"cwd": tmp_path, "capture_output": True, "text": True, "check": True}) + _utf8 = {"encoding": "utf-8", "errors": "replace"} + assert calls[0] == (["git", "stash", "apply", "abc123"], {"cwd": tmp_path, "capture_output": True, "text": True, **_utf8}) + assert calls[1] == (["git", "diff", "--name-only", "--diff-filter=U"], {"cwd": tmp_path, "capture_output": True, "text": True, **_utf8}) + assert calls[2] == (["git", "stash", "list", "--format=%gd %H"], {"cwd": tmp_path, "capture_output": True, "text": True, **_utf8, "check": True}) out = capsys.readouterr().out assert "couldn't find the stash entry to drop" in out assert "stash was left in place" in out diff --git a/tests/tools/test_docker_environment.py b/tests/tools/test_docker_environment.py index d468de66fb71..a2a6f79a595f 100644 --- a/tests/tools/test_docker_environment.py +++ b/tests/tools/test_docker_environment.py @@ -116,6 +116,8 @@ def test_ensure_docker_available_uses_resolved_executable(monkeypatch): (["/opt/homebrew/bin/docker", "version"], { "capture_output": True, "text": True, + "encoding": "utf-8", + "errors": "replace", "timeout": 5, "stdin": subprocess.DEVNULL, }) diff --git a/tools/computer_use/doctor.py b/tools/computer_use/doctor.py index 5e5cdf45e8ef..54fad0666844 100644 --- a/tools/computer_use/doctor.py +++ b/tools/computer_use/doctor.py @@ -99,7 +99,7 @@ def _drive_health_report( stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - text=True, encoding='utf-8', errors='replace', + text=True, encoding="utf-8", errors="replace", bufsize=1, diff --git a/tools/environments/local.py b/tools/environments/local.py index 701b1951e2f0..673d8a3345e5 100644 --- a/tools/environments/local.py +++ b/tools/environments/local.py @@ -1403,7 +1403,7 @@ class LocalEnvironment(BaseEnvironment): proc = subprocess.Popen( args, - text=True, encoding='utf-8', errors='replace', + text=True, env=run_env, encoding="utf-8", errors="replace",