fix: add explicit encoding="utf-8" to open() calls for cross-platform safety#15519
Closed
vominh1919 wants to merge 1 commit into
Closed
fix: add explicit encoding="utf-8" to open() calls for cross-platform safety#15519vominh1919 wants to merge 1 commit into
vominh1919 wants to merge 1 commit into
Conversation
… safety On Windows, open() without an explicit encoding parameter defaults to the system locale encoding (often cp1252). When config.yaml or metadata files contain non-ASCII characters (CJK text, emoji, accented names), this causes UnicodeDecodeError on read or data corruption on write. This change adds encoding="utf-8" to 17 open() calls across 10 source files that read/write YAML config, JSON metadata, or text data. All are text-mode opens that handle user-editable content. Affected files: - tui_gateway/server.py (config load/save, conversation export) - hermes_time.py (timezone config) - rl_cli.py (RL config) - hermes_cli/profiles.py (profile config) - cron/scheduler.py (cron config) - agent/model_metadata.py (context length cache) - agent/nous_rate_guard.py (rate limit state) - plugins/memory/__init__.py (plugin metadata) - plugins/memory/holographic/__init__.py (holographic config) - plugins/context_engine/__init__.py (context engine metadata)
This was referenced Apr 28, 2026
3 tasks
Contributor
|
Closing as already fixed on Triage notes (high confidence): If you still see this on the latest version, please reopen with reproduction steps. (Bulk-closed during a CLI triage sweep.) |
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
On Windows,
open()without an explicitencodingparameter defaults to the system locale encoding (oftencp1252). Whenconfig.yamlor metadata files contain non-ASCII characters (CJK text, emoji, accented names, Unicode model identifiers), this causes:UnicodeDecodeErroron read — the user's config silently fails to load, and the agent falls back to defaults with no visible errorThis is the same class of bug that Python's documentation warns about: Unicode HOWTO — Reading and Writing Unicode Files.
Before vs After
config.yamlwithtimezone: "Asia/Tokyo"on Windows (cp1252)UnicodeDecodeError→ silent fallback to defaultsUnicodeDecodeError→ empty descriptionUnicodeEncodeError→ export failsFix
Added
encoding="utf-8"to 17open()calls across 10 source files that read/write YAML config, JSON metadata, or text data. All are text-mode opens that handle user-editable content.Affected files
tui_gateway/server.pyhermes_time.pyrl_cli.pyhermes_cli/profiles.pycron/scheduler.pyagent/model_metadata.pyagent/nous_rate_guard.pyplugins/memory/__init__.pyplugins/memory/holographic/__init__.pyplugins/context_engine/__init__.pyWhy this is safe
encoding="utf-8"is a no-op on Linux/macOS where the default is already UTF-8encoding="utf-8"correctly in ~15 other files (e.g.,cron/jobs.py,utils.py,gateway/channel_directory.py) — this PR brings the remaining files into consistencyTesting
Verified with
git diffthat each change is a minimal, targeted addition ofencoding="utf-8"to theopen()call with no other modifications. All changed files parse correctly as Python.