René's URL Explorer Experiment


Title: fix(config): preserve unicode characters when writing yaml config by bearomorphism · Pull Request #1966 · commitizen-tools/commitizen · GitHub

Open Graph Title: fix(config): preserve unicode characters when writing yaml config by bearomorphism · Pull Request #1966 · commitizen-tools/commitizen

X Title: fix(config): preserve unicode characters when writing yaml config by bearomorphism · Pull Request #1966 · commitizen-tools/commitizen

Description: Description Closes #1164. Why PyYAML's yaml.dump defaults to ASCII-only output: any non-ASCII codepoint is escaped using Python's \Uxxxx notation. This means a .cz.yaml containing a literal emoji — for example 🚀 in bump_message — is silently mangled every time cz bump rewrites the config, replacing the readable character with \U0001F680. Reported by @syepes on commitizen 3.27.0 / Python 3.12 / macOS (#1164), with before-and-after screenshots showing the escape introduced by cz bump --increment PATCH. A triage note from the open-issues audit (2026-05-09) confirmed the bug still reproduces on master (v4.15.1): after cz bump, the bump_message key reads "\U0001F680 chore(release): …" instead of "🚀 chore(release): …". The root cause is that both yaml.dump call sites in commitizen/config/yaml_config.py — init_empty_config_content (line 33) and set_key (line 66) — omit allow_unicode=True. PyYAML documents that this flag causes non-ASCII codepoints to be written as literal UTF-8 bytes rather than escape sequences; the output remains valid YAML and valid UTF-8. What changed File Change commitizen/config/yaml_config.py Add allow_unicode=True to yaml.dump in init_empty_config_content (line 33) and in set_key (line 66) tests/test_conf.py Add test_set_key_preserves_unicode (regression: emoji survives a set_key round-trip) and test_init_empty_config_content_passes_allow_unicode (spy: keyword argument is forwarded to yaml.dump) How it works set_key (commitizen/config/yaml_config.py:58–68): reads the config with yaml.load, mutates the target key in the parsed dict, then re-serialises with yaml.dump. Without allow_unicode=True, any non-ASCII character already present in the file is escaped on write-back — producing the \U0001F680 symptom. Adding the flag instructs PyYAML to emit those characters as literal UTF-8 bytes. init_empty_config_content (commitizen/config/yaml_config.py:29–33): writes {"commitizen": {}} in append mode during cz init. Its payload is currently ASCII-only, so allow_unicode=True has no observable effect today. It is added for consistency and to guard against future default content that might include non-ASCII characters. Test strategy: test_set_key_preserves_unicode writes a YAML file containing 🚀, calls set_key("version", "0.1.1"), and asserts both that 🚀 survives and that \U0001F680 does not appear — this is the direct regression test for #1164. test_init_empty_config_content_passes_allow_unicode uses mocker.spy(yaml, "dump") to assert the keyword is forwarded rather than testing round-trip behaviour that does not currently occur (see the review note in Additional Context). Why not a custom Dumper? PyYAML's allow_unicode flag is the documented, single-argument way to opt out of ASCII escaping. A custom Dumper subclass would be substantially more complex and carries a maintenance burden with no additional benefit for this use case. Backward compatibility YAML files that already contain \Uxxxx escape sequences are normalised on the next cz bump: yaml.load decodes the escape to the Unicode character on read, and the subsequent yaml.dump re-emits it as a literal codepoint. No data is lost and no manual migration is needed. All 20 existing TestYamlConfig tests in tests/test_conf.py pass without modification. No change to the public API, CLI flags, exit codes, or any config backend other than YAMLConfig. Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-by: Claude following the guidelines Code Changes Add test cases to all the changes you introduce Run uv run poe all locally to ensure this change passes linter check and tests Manually test the changes (see "Steps to Test" below) Update the documentation for the changes Expected Behavior Scenario Outcome .cz.yaml has bump_message: "🚀 chore: bump …" and cz bump is run Emoji 🚀 is preserved verbatim; \U0001F680 does not appear .cz.yaml already contains an escaped \U0001F680 and cz bump is run PyYAML normalises the escape on read and re-emits the literal 🚀 — file is healed in place cz init creates a new .cz.yaml Output is ---\ncommitizen: {}\n, identical to the pre-fix behaviour Steps to Test This Pull Request git fetch fork fix/1164-yaml-allow-unicode git checkout fork/fix/1164-yaml-allow-unicode # 1. Targeted regression test. uv run pytest tests/test_conf.py::TestYamlConfig::test_set_key_preserves_unicode \ tests/test_conf.py::TestYamlConfig::test_init_empty_config_content_passes_allow_unicode -v # 2. Reproduce the bug, then verify the fix. mkdir /tmp/cz-1164 && cd /tmp/cz-1164 git init -b main git config user.name test && git config user.email test@example.com cat > .cz.yaml << 'EOF' commitizen: name: cz_conventional_commits version: 0.1.0 tag_format: "v$version" bump_message: "🚀 chore(release): bump $current_version to $new_version" EOF git add .cz.yaml && git commit -m "feat: initial" cz bump --increment PATCH --yes grep bump_message .cz.yaml # Expected: bump_message: "🚀 chore(release): ..." # NOT: bump_message: "\U0001F680 chore(release): ..." Additional Context This fix was identified during the open-issues audit tracked in #1964. A triage note (@bearomorphism, 2026-05-09) confirmed the bug reproduces on master (v4.15.1) and pinpointed commitizen/config/yaml_config.py:66 as the root cause, with a symmetric fix needed at line 33 for consistency. Review note — test update: the initial draft included test_init_empty_config_content_uses_allow_unicode, which pre-seeded a YAML file with 🚀 and asserted the emoji survived init_empty_config_content(). This was misleading: because init_empty_config_content opens in append mode and writes only {"commitizen": {}}, the assertion would pass regardless of whether allow_unicode=True was present. The test has been replaced with a mocker.spy-based assertion that directly verifies the keyword argument is forwarded, without pretending to test behaviour that doesn't currently happen (see PR comment).

Open Graph Description: Description Closes #1164. Why PyYAML's yaml.dump defaults to ASCII-only output: any non-ASCII codepoint is escaped using Python's \Uxxxx notation. This means a .cz.yaml containing a literal...

X Description: Description Closes #1164. Why PyYAML&#39;s yaml.dump defaults to ASCII-only output: any non-ASCII codepoint is escaped using Python&#39;s \Uxxxx notation. This means a .cz.yaml containing a...

Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1966

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5838f331-c4a0-4c0d-c64b-7f8b99921513
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD934:3B269:1323B97:1A7DF16:6A4DE8AF
html-safe-nonceebde472d3b16257071282a68d1ba26990f19c138192c5893e220b11fb1d2916a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTM0OjNCMjY5OjEzMjNCOTc6MUE3REYxNjo2QTRERThBRiIsInZpc2l0b3JfaWQiOiIzNjcxODE5ODAwMDAwOTgxMTY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8a7935d6370e0720c8e0dd37d6bc9009ebeeea1100f10575cbfd1ec301ff6fee
hovercard-subject-tagpull_request:3654638820
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1966/files
twitter:imagehttps://avatars.githubusercontent.com/u/26526132?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/26526132?s=400&v=4
og:image:altDescription Closes #1164. Why PyYAML's yaml.dump defaults to ASCII-only output: any non-ASCII codepoint is escaped using Python's \Uxxxx notation. This means a .cz.yaml containing a literal...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git
octolytics-dimension-user_id62252524
octolytics-dimension-user_logincommitizen-tools
octolytics-dimension-repository_id106127589
octolytics-dimension-repository_nwocommitizen-tools/commitizen
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id106127589
octolytics-dimension-repository_network_root_nwocommitizen-tools/commitizen
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/commitizen-tools/commitizen/pull/1966/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1966%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1966%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=commitizen-tools%2Fcommitizen
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1966/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1966/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1966/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1966/files
commitizen-tools https://github.com/commitizen-tools
commitizenhttps://github.com/commitizen-tools/commitizen
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1966/files
Notifications https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Fork 343 https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Star 3.5k https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Code https://github.com/commitizen-tools/commitizen
Issues 116 https://github.com/commitizen-tools/commitizen/issues
Pull requests 45 https://github.com/commitizen-tools/commitizen/pulls
Discussions https://github.com/commitizen-tools/commitizen/discussions
Actions https://github.com/commitizen-tools/commitizen/actions
Projects https://github.com/commitizen-tools/commitizen/projects
Security and quality 0 https://github.com/commitizen-tools/commitizen/security
Insights https://github.com/commitizen-tools/commitizen/pulse
Code https://github.com/commitizen-tools/commitizen
Issues https://github.com/commitizen-tools/commitizen/issues
Pull requests https://github.com/commitizen-tools/commitizen/pulls
Discussions https://github.com/commitizen-tools/commitizen/discussions
Actions https://github.com/commitizen-tools/commitizen/actions
Projects https://github.com/commitizen-tools/commitizen/projects
Security and quality https://github.com/commitizen-tools/commitizen/security
Insights https://github.com/commitizen-tools/commitizen/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fcommitizen-tools%2Fcommitizen%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen%2Fissues%2Fnew%2Fchoose
bearomorphismhttps://github.com/bearomorphism
commitizen-tools:masterhttps://github.com/commitizen-tools/commitizen/tree/master
bearomorphism:fix/1164-yaml-allow-unicodehttps://github.com/bearomorphism/commitizen/tree/fix/1164-yaml-allow-unicode
Conversation 9 https://github.com/commitizen-tools/commitizen/pull/1966
Commits 2 https://github.com/commitizen-tools/commitizen/pull/1966/commits
Checks 20 https://github.com/commitizen-tools/commitizen/pull/1966/checks
Files changed https://github.com/commitizen-tools/commitizen/pull/1966/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1966/files
fix(config): preserve unicode characters when writing yaml config https://github.com/commitizen-tools/commitizen/pull/1966/files#top
Show all changes 2 commits https://github.com/commitizen-tools/commitizen/pull/1966/files
b404143 fix(config): preserve unicode characters when writing yaml config bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1966/commits/b404143e6a013b4808151ab6db0ee9e2d2f815b9
56bca18 fix(yaml-config): address PR #1966 reviewer feedback bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1966/commits/56bca188eb04d2d6b0cd6dad1e995d299ca256dc
Clear filters https://github.com/commitizen-tools/commitizen/pull/1966/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1966/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1966/files
yaml_config.py https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-1aff2b95c87ebe1dee4da8637ca9aa66bdb5dc607b21340248a6196408469604
test_conf.py https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-6468e768366adbe7dd3205f161126966a694d5ddc2aa94a1e50a6d4da339139f
commitizen/config/yaml_config.pyhttps://github.com/commitizen-tools/commitizen/pull/1966/files#diff-1aff2b95c87ebe1dee4da8637ca9aa66bdb5dc607b21340248a6196408469604
View file https://github.com/commitizen-tools/commitizen/blob/56bca188eb04d2d6b0cd6dad1e995d299ca256dc/commitizen/config/yaml_config.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1966/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-1aff2b95c87ebe1dee4da8637ca9aa66bdb5dc607b21340248a6196408469604
https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-1aff2b95c87ebe1dee4da8637ca9aa66bdb5dc607b21340248a6196408469604
https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-1aff2b95c87ebe1dee4da8637ca9aa66bdb5dc607b21340248a6196408469604
tests/test_conf.pyhttps://github.com/commitizen-tools/commitizen/pull/1966/files#diff-6468e768366adbe7dd3205f161126966a694d5ddc2aa94a1e50a6d4da339139f
View file https://github.com/commitizen-tools/commitizen/blob/56bca188eb04d2d6b0cd6dad1e995d299ca256dc/tests/test_conf.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1966/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-6468e768366adbe7dd3205f161126966a694d5ddc2aa94a1e50a6d4da339139f
https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-6468e768366adbe7dd3205f161126966a694d5ddc2aa94a1e50a6d4da339139f
https://github.com/commitizen-tools/commitizen/pull/1966/files#diff-6468e768366adbe7dd3205f161126966a694d5ddc2aa94a1e50a6d4da339139f
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1966/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.