Skip to content

fix: add explicit encoding to read_text()/write_text() calls - #51366

Closed
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:alex/fix-encoding-default
Closed

fix: add explicit encoding to read_text()/write_text() calls#51366
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:alex/fix-encoding-default

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Problem

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 UnicodeDecodeError on non-ASCII content.

Fix

Add explicit encoding="utf-8" to all affected call sites:

  • agent/auxiliary_client.py: _read_nous_auth() JSON load
  • agent/credential_sources.py: .env file scanning (already had errors="replace" but no encoding)
  • 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

Context

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.

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
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets tool/skills Skills system (list, view, manage) platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows P3 Low — cosmetic, nice to have labels Jun 23, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/skills Skills system (list, view, manage) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants