Skip to content

fix(bundler): dump_yaml writes literal UTF-8 (allow_unicode=True)#3660

Merged
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/bundler-yamlio-allow-unicode
Jul 23, 2026
Merged

fix(bundler): dump_yaml writes literal UTF-8 (allow_unicode=True)#3660
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/bundler-yamlio-allow-unicode

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

What

dump_yaml (bundler/lib/yamlio.py) called yaml.safe_dump without allow_unicode=True, so any non-ASCII content was written as \xNN / \uXXXX escape sequences instead of literal UTF-8 — e.g. café-münchen became "caf\xE9-m\xFCnchen" in the file. That's a round-trip readability loss for any bundle config carrying accented or non-Latin text.

Why it matters

The centralized frontmatter helper _utils.dump_frontmatter explicitly passes allow_unicode=True and documents it so "no call site can silently drop" unicode, and the extensions/presets config writers (extensions/_commands.py, presets/_commands.py) all do the same. dump_yaml was the outlier.

Fix

Add allow_unicode=True to the safe_dump call, matching the sibling writers.

Tests

tests/unit/test_bundler_yamlio.py:

  • test_dump_yaml_preserves_unicode — asserts literal café-münchen / 例え in the output and no \x/\u escapes (fails before the fix)
  • test_dump_yaml_round_trips_unicodeload_yaml(dump_yaml(...)) round-trips

ruff clean.


AI-assisted: authored with Claude Code. Verified against the dump_frontmatter / extensions / presets sibling writers and confirmed fail-before/pass-after.

dump_yaml called yaml.safe_dump without allow_unicode=True, so non-ASCII
content was written as \xNN / \uXXXX escapes instead of literal UTF-8 — a
round-trip readability loss for bundle config. The centralized helper
_utils.dump_frontmatter and the extensions/presets config writers all pass
allow_unicode=True; align dump_yaml with them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates bundler YAML serialization to preserve literal UTF-8 text.

Changes:

  • Enables allow_unicode=True in dump_yaml.
  • Adds tests for readable Unicode output and round-trip integrity.
Show a summary per file
File Description
src/specify_cli/bundler/lib/yamlio.py Preserves Unicode characters when writing YAML.
tests/unit/test_bundler_yamlio.py Verifies Unicode serialization and loading.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@mnriem
mnriem merged commit 5e384bb into github:main Jul 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants