fix(workflows): keep non-ASCII text readable in written overlay files - #4148
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): keep non-ASCII text readable in written overlay files#4148jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
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>
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
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.