fix(config): preserve non-ASCII paths in written JSON configs (#497)#682
Open
Chang-Jin-Lee wants to merge 1 commit into
Open
fix(config): preserve non-ASCII paths in written JSON configs (#497)#682Chang-Jin-Lee wants to merge 1 commit into
Chang-Jin-Lee wants to merge 1 commit into
Conversation
…205#497) json.dumps(..., indent=2) defaults to ensure_ascii=True, so the 6 config writers that round-trip a repo path or arbitrary pre-existing content through it all serialize non-ASCII as literal \uXXXX escapes instead of native UTF-8: - skills.py: install_platform_configs (.mcp.json cwd field), the shared _merge_hooks_into_settings (Claude settings.json), install_codex_hooks (Codex hooks.json), install_gemini_cli_hooks (Gemini settings.json), install_cursor_hooks (Cursor hooks.json) - registry.py: Registry._save (registry.json) Technically valid JSON either way, but as tirth8205#497 documents, some MCP hosts / process launchers don't correctly decode \uXXXX when consuming these files directly. The issue's Bug 1 (json.dumps() abused for shell quoting, causing the reported corrupted-desktop-directory-tree symptom) looks already fixed elsewhere — repo paths are now substituted into hook scripts as plain strings, not JSON-encoded. This closes out the remaining Bug 2 scope: writing native UTF-8 in every config file this tool touches. Added a regression test per site (6 total) seeding non-ASCII content and asserting the raw written file contains literal UTF-8, not \u escapes. Written first and watched fail (RED) before adding ensure_ascii=False (GREEN). Co-Authored-By: Claude Fable 5 <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.
Linked issue
Closes #497 (remaining scope — see below)
What & why
json.dumps(existing, indent=2)defaults toensure_ascii=True, so every config writer that round-trips a repo path or arbitrary pre-existing content through it serializes non-ASCII as literal\uXXXXescapes instead of native UTF-8. Six sites still had this:skills.py:install_platform_configs(.mcp.jsoncwdfield), the shared_merge_hooks_into_settings(Claudesettings.json),install_codex_hooks(Codexhooks.json),install_gemini_cli_hooks(Geminisettings.json),install_cursor_hooks(Cursorhooks.json)registry.py:Registry._save(registry.json)Technically valid JSON either way, but as #497 documents, some MCP hosts / process launchers don't correctly decode
\uXXXXwhen consuming these files directly.One correction on scope: I believe #497's Bug 1 (
json.dumps()abused for shell quoting, which is what actually produced the reported corruptedu57fa/u4e8e.../desktop directory tree via double-encoding) is already fixed — the repo path is now substituted into hook scripts as a plain string, not JSON-encoded, so there's no longer a double-encode step for that specific flow. This PR closes out the remaining Bug 2 scope from the issue's "Affected locations" table: writing native UTF-8 in every config file this tool touches, which is still worth doing defensively (and is what a couple of those table rows asked for independent of Bug 1).How it was tested
Added one regression test per site (6 total, in
TestNonAsciiConfigPreservationintest_skills.pyandTestRegistryNonAsciiintest_registry.py): seed non-ASCII content (a repo path or a pre-existing custom field), run the writer, assert the raw written file contains the literal UTF-8 characters and no\uescapes. Written first and watched fail (RED — every one failed with\uXXXXin the output) before addingensure_ascii=False(GREEN).Checklist
uv run pytest tests/ --tb=short -quv run ruff check code_review_graph/uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional