From cf83982da0fd33a7030e88b65c298167d9abdbc9 Mon Sep 17 00:00:00 2001 From: Kailigithub <12250313+Kailigithub@users.noreply.github.com> Date: Wed, 29 Apr 2026 05:08:01 -0700 Subject: [PATCH] fix(gateway): handle wmic encoding errors on Windows non-English locales Pass encoding='utf-8', errors='ignore' and guard against result.stdout being None so _scan_gateway_pids() no longer crashes with UnicodeDecodeError + AttributeError on Windows systems whose default code page is not UTF-8 (e.g. cp936 on zh-CN). The parser only matches the ASCII prefixes CommandLine= and ProcessId=, so dropping undecodable bytes is safe. Closes #17049. --- hermes_cli/gateway.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index e05410a78..3ee4dbafe 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -279,9 +279,11 @@ def _scan_gateway_pids(exclude_pids: set[int], all_profiles: bool = False) -> li ["wmic", "process", "get", "ProcessId,CommandLine", "/FORMAT:LIST"], capture_output=True, text=True, + encoding="utf-8", + errors="ignore", timeout=10, ) - if result.returncode != 0: + if result.returncode != 0 or result.stdout is None: return [] current_cmd = "" for line in result.stdout.split("\n"):