fix(tools,agent): add explicit encoding to read_text/write_text calls - #50660
fix(tools,agent): add explicit encoding to read_text/write_text calls#50660AlexFucuson9 wants to merge 1 commit into
Conversation
Path.read_text() and write_text() without encoding default to system locale. On Windows this is cp1252, causing UnicodeDecodeError for UTF-8 content. Add encoding="utf-8" to 22 calls across 7 files: - tools/skills_hub.py: 15 calls (read + write) - agent/auxiliary_client.py: 1 read_text - agent/copilot_acp_client.py: 1 read + 1 write - agent/shell_hooks.py: 1 read_text - tools/managed_tool_gateway.py: 1 read_text - tools/skills_sync.py: 1 read_text - tools/xai_http.py: 1 read_text
heliamuso
left a comment
There was a problem hiding this comment.
Hermes Agent Review — PR #50660
Verdict: Changes Requested
🔴 Critical Bug Found
tools/skills_hub.py:3320 — Duplicate encoding keyword argument.
The old line already had encoding="utf-8", the find-and-replace doubled it:
file_dest.write_text(file_content, encoding="utf-8", encoding="utf-8")This raises TypeError: write_text() got multiple values for keyword argument encoding at runtime. Fix:
file_dest.write_text(file_content, encoding="utf-8")✅ Everything Else Looks Good
The other 21 changes across 6 files are correct. Clean, focused PR otherwise.
Reviewed by Hermes Agent via github-code-review skill
| file_dest.write_bytes(file_content) | ||
| else: | ||
| file_dest.write_text(file_content, encoding="utf-8") | ||
| file_dest.write_text(file_content, encoding="utf-8", encoding="utf-8") |
There was a problem hiding this comment.
🔴 Critical: Duplicate encoding="utf-8" keyword argument. The old line already had encoding="utf-8" — the find-and-replace doubled it. This causes TypeError: write_text() got multiple values for keyword argument encoding at runtime.
Fix: remove the second encoding="utf-8".
heliamuso
left a comment
There was a problem hiding this comment.
Test: fine-grained PAT GraphQL access works!
Summary
Companion to PR #50655 (hermes_cli/ files). Add
encoding="utf-8"to remainingread_text()/write_text()calls intools/andagent/directories.7 files, 22 calls fixed:
tools/skills_hub.py: 15 calls (read + write)agent/auxiliary_client.py: 1 read_textagent/copilot_acp_client.py: 1 read + 1 writeagent/shell_hooks.py: 1 read_texttools/managed_tool_gateway.py: 1 read_texttools/skills_sync.py: 1 read_texttools/xai_http.py: 1 read_textTest plan