fix(workflows): keep non-ASCII text readable in written overlay files - #4148
Merged
Conversation
Both overlay writers in `overlays/_commands.py` called
`yaml.safe_dump(data, sort_keys=False)` without `allow_unicode=True`, so
every non-ASCII character was rewritten as a `\uXXXX` / `\xNN` escape inside
a double-quoted scalar. Every other YAML writer in the repo already passes
`allow_unicode=True` (agents.py, bundler/lib/yamlio.py, extensions,
integrations/base.py, ...).
Overlay files are explicitly hand-authored and hand-edited -- the format is
documented in docs/reference/workflows.md and users are told to write these
files. `overlay add`, `enable`, `disable` and `set-priority` all round-trip
the file through `safe_dump`, so merely toggling an overlay mangled a UTF-8
file the user wrote by hand:
message: "Revisar el plan — \xBFaprobar? 日本語"
The value still parses back identically, so this is not corruption -- it is
the loss of a documented, hand-edited file's legibility.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
mnriem
requested a balanced review from
Problem
Both overlay writers in
overlays/_commands.py(lines 217 and 270 — the only twoyaml.safe_dumpcalls in the module) omitallow_unicode=True:So every non-ASCII character in a user's overlay is rewritten as a
\uXXXX/\xNNescape inside a double-quoted scalar.Every other YAML writer in the repo already passes
allow_unicode=True:Why it matters
Overlay files are explicitly hand-authored and hand-edited —
docs/reference/workflows.mddocuments the file format and tells users to write these files.overlay add,enable,disableandset-priorityall round-trip the file throughsafe_dump, so merely toggling an overlay mangles a UTF-8 file the user wrote by hand.Reproduction on current
mainSource overlay written in UTF-8 with
message: "Revisar el plan — ¿aprobar? 日本語", thenspecify workflow overlay add overlay.yml:The value still parses back identically, so this is not corruption — it is the loss of a documented, hand-edited file's legibility, the same thing
allow_unicode=Trueis already there to prevent everywhere else.Verification
overlay add(the install path) andoverlay set-priority(the_update_overlay_fieldround-trip path).yaml.safe_load.tests/workflows: no new failures vs a clean-mainbaseline (10 pre-existing, Windows symlink-privilege).uvx ruff@0.15.0 check src tests→ cleanNo breaking change.
allow_unicodeonly affects how characters are encoded in the output; the parsed value is byte-identical either way (both new tests assert this explicitly), and files are already written as UTF-8 via.encode("utf-8"). Pure-ASCII overlays — the overwhelming majority — produce identical bytes.Written with assistance from Claude Code. Bug found, reproduced, and verified by me on current
main.