fix: add explicit encoding to read_text()/write_text() calls - #51366
Closed
AlexFucuson9 wants to merge 1 commit into
Closed
fix: add explicit encoding to read_text()/write_text() calls#51366AlexFucuson9 wants to merge 1 commit into
AlexFucuson9 wants to merge 1 commit into
Conversation
Several files call Path.read_text() or Path.write_text() without specifying encoding. On Windows, this defaults to the system codepage (typically cp1252), which corrupts or raises on non-ASCII content. Affected call sites: - agent/auxiliary_client.py: _read_nous_auth() JSON load - agent/credential_sources.py: .env file scanning - agent/copilot_acp_client.py: file read/write in ACP shim - agent/shell_hooks.py: allowlist JSON load - tools/managed_tool_gateway.py: provider state JSON load - tools/skills_sync.py: hub lock.json load
tonydwb
reviewed
Jun 23, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
This PR adds encoding="utf-8" to read_text()/write_text() calls across 7 files. The changes are correct.
However, this is the fourth PR from AlexFucuson9 covering the same encoding fix pattern:
- #51406:
nous_rate_guard.py,shell_hooks.py,slash_commands.py - #51388:
nous_rate_guard.py,shell_hooks.py(subset of #51406) - #51373:
gateway.py,skills_hub.py,xai_http.py - This PR (#51366):
auxiliary_client.py,copilot_acp_client.py,credential_sources.py,shell_hooks.py,managed_tool_gateway.py,skills_sync.py
Note: shell_hooks.py is covered by all four PRs. The other files in this PR are unique to it. Consider whether consolidating into fewer PRs would be cleaner.
Reviewed by Hermes Agent
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several files call
Path.read_text()orPath.write_text()without specifyingencoding. On Windows, this defaults to the system codepage (typically cp1252), which corrupts or raisesUnicodeDecodeErroron non-ASCII content.Fix
Add explicit
encoding="utf-8"to all affected call sites:agent/auxiliary_client.py:_read_nous_auth()JSON loadagent/credential_sources.py:.envfile scanning (already haderrors="replace"but no encoding)agent/copilot_acp_client.py: file read/write in ACP shimagent/shell_hooks.py: allowlist JSON loadtools/managed_tool_gateway.py: provider state JSON loadtools/skills_sync.py: hub lock.json loadContext
The rest of the codebase already uses
encoding="utf-8"consistently (e.g.agent/curator.py,agent/skill_bundles.py,agent/curator_backup.py). These 6 files are the remaining outliers.