From 7993e03c436b07af4aa0eb016e4587255754ec32 Mon Sep 17 00:00:00 2001 From: JonthanaHanh <92574114+JonthanaHanh@users.noreply.github.com> Date: Thu, 23 Jul 2026 10:10:43 +0700 Subject: [PATCH] fix(auth): specify UTF-8 encoding for auth.json read_text() calls On Windows with CJK usernames, locale.getpreferredencoding() returns GBK (or similar). Path.read_text() without an explicit encoding uses the system default, so reading a UTF-8 JSON file under a GBK locale raises UnicodeDecodeError. Add encoding="utf-8" to all three read_text() calls that parse auth.json files, matching the pattern already used for write_text() and lock file operations. Fixes #69706 --- hermes_cli/auth.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hermes_cli/auth.py b/hermes_cli/auth.py index 507dd08a0220..4b2c01088956 100644 --- a/hermes_cli/auth.py +++ b/hermes_cli/auth.py @@ -1112,7 +1112,7 @@ def _load_auth_store(auth_file: Optional[Path] = None) -> Dict[str, Any]: return {"version": AUTH_STORE_VERSION, "providers": {}} try: - raw = json.loads(auth_file.read_text()) + raw = json.loads(auth_file.read_text(encoding="utf-8")) except Exception as exc: corrupt_path = auth_file.with_suffix(".json.corrupt") try: @@ -3701,7 +3701,7 @@ def _import_codex_cli_tokens() -> Optional[Dict[str, str]]: if not auth_path.is_file(): return None try: - payload = json.loads(auth_path.read_text()) + payload = json.loads(auth_path.read_text(encoding="utf-8")) tokens = payload.get("tokens") if not isinstance(tokens, dict): return None @@ -5136,7 +5136,7 @@ def _read_shared_nous_state() -> Optional[Dict[str, Any]]: if not path.is_file(): return None try: - payload = json.loads(path.read_text()) + payload = json.loads(path.read_text(encoding="utf-8")) except (OSError, ValueError) as exc: logger.debug("Shared Nous auth store at %s is unreadable: %s", path, exc) return None