From 2f2d90344c8dfa6898d23371db5fb80aa638f7d3 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Fri, 31 Jul 2026 22:05:02 -0700 Subject: [PATCH] fix(copilot): add explicit UTF-8 encoding to JWT store read/write Matches the repo-wide convention (c89481db5e); unblocks ruff enforcement and the Windows footgun checker on the salvaged JWT persistence code. --- hermes_cli/copilot_auth.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hermes_cli/copilot_auth.py b/hermes_cli/copilot_auth.py index 6cad6d0906..1b4ac33028 100644 --- a/hermes_cli/copilot_auth.py +++ b/hermes_cli/copilot_auth.py @@ -331,7 +331,7 @@ def _read_jwt_store(path: Path) -> Optional[dict]: "Persisted Copilot JWT store exceeds %d bytes; ignoring", _JWT_DISK_MAX_BYTES ) return None - loaded = json.loads(path.read_text()) + loaded = json.loads(path.read_text(encoding="utf-8")) return loaded if isinstance(loaded, dict) else None except Exception as exc: logger.debug("Failed to read persisted Copilot JWT store: %s", exc) @@ -360,7 +360,7 @@ def evict_cached_exchanged_token(raw_token: str) -> None: if store is not None and fp in store: del store[fp] tmp = path.with_suffix(path.suffix + ".tmp") - tmp.write_text(json.dumps(store)) + tmp.write_text(json.dumps(store), encoding="utf-8") try: os.chmod(tmp, 0o600) except Exception: @@ -425,7 +425,7 @@ def _save_jwt_to_disk( "base_url": base_url, } tmp = path.with_suffix(path.suffix + ".tmp") - tmp.write_text(json.dumps(store)) + tmp.write_text(json.dumps(store), encoding="utf-8") try: os.chmod(tmp, 0o600) except Exception: