Skip to content

storage: read_text/write_text without encoding='utf-8' breaks on Windows non-UTF8 locales #60

Description

@brandwe

File: src/entrabot/storage/persona.py
Location: L93, L109, L134 (+ migration.py L82, backend.py L78/83/89)
Category: bug
Priority: low

Description

Python 3.12 defaults to the locale encoding on Windows (cp1252, cp932, etc.) unless PYTHONUTF8=1. Claude Code persona memory is UTF-8 markdown commonly containing non-ASCII (emojis, smart quotes). On a Windows host without UTF-8 mode, PersonaBackend.push_one will UnicodeDecodeError reading a file containing non-ASCII, and pull_all's dst.write_text(content) can UnicodeEncodeError. Migration's path.read_text() has the same problem. The codebase explicitly supports Windows.

Suggested fix

Add encoding="utf-8" to every read_text / write_text in storage code (backend.py, persona.py, migration.py). Consider errors="replace" on reads if forgiveness is preferred to surfacing the error.


Filed automatically by a thorough code-review pass over src/entrabot/ on 2026-06-13. Internal review id: #39.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions