fix: add encoding='utf-8' to read_text/write_text in plugins/ (35 sites, 13 files) - #65569
fix: add encoding='utf-8' to read_text/write_text in plugins/ (35 sites, 13 files)#65569AlexFucuson9 wants to merge 1 commit into
Conversation
Path.read_text() and .write_text() without encoding default to the system locale (cp1252 on Windows), silently corrupting non-ASCII content. The project's PLW1514 ruff rule only catches open() calls, not Path API variants. Fix 35 call sites across 13 plugin files covering: - Platform adapters: discord, telegram, feishu, whatsapp, google_chat - Memory plugins: mem0, hindsight, honcho - Utility plugins: disk-cleanup, google_meet, hermes-achievements
|
Thanks for addressing the plugin-side Windows encoding gap. The premise is confirmed on current main: e.g. Problems
Suggested changes
Automated hermes-sweeper review. |
|
Closing as resolved by PR #71078 (merged, commit d372fda): the class-wide close-out salvaged your #50655/#54241/#56385/#66856/#65440 series as the backbone (authorship preserved in git log) and swept the remaining sites, so every read_text/write_text call this PR touches is now guarded on current main — verified per-site. A CI linter rule in check-windows-footguns.py plus the AST guard test now prevent regressions. Your overlapping/split variants of the same series are being closed together; the credit for the class rests on your commits. |
Summary
Add explicit
encoding="utf-8"to allPath.read_text()and.write_text()calls in plugins/ that were missing it.Problem
Path.read_text()and.write_text()withoutencoding=default to the system locale:The project's ruff rule PLW1514 only flags
open()calls —Path.read_text()and.write_text()are not caught by linting.Changes (13 files, 35 call sites)
Platform adapters:
plugins/platforms/discord/adapter.py— update prompt answer writeplugins/platforms/telegram/adapter.py— update prompt answer writeplugins/platforms/feishu/adapter.py— update prompt answer writeplugins/platforms/whatsapp/adapter.py— bridge PID + dep stamp (4 sites)plugins/platforms/google_chat/oauth.py— credential JSON read (2 sites)plugins/platforms/google_chat/adapter.py— counts JSON + bot user ID (4 sites)Memory plugins:
plugins/memory/mem0/_setup.py— env file + config JSON (6 sites)plugins/memory/mem0/__init__.py— config readplugins/memory/hindsight/__init__.py— config + env file (4 sites)plugins/memory/honcho/__init__.py— config readUtility plugins:
plugins/disk-cleanup/disk_cleanup.py— tracked state JSON (3 sites)plugins/google_meet/realtime/openai_client.py— queue file (3 sites)plugins/hermes-achievements/dashboard/plugin_api.py— state JSON (6 sites)Risk
None — UTF-8 is correct for all JSON/text config files. No-op on Linux, correctness fix on Windows.