Skip to content

fix(mcp): preserve UTF-8 when reading JSONC configs - #1325

Open
AmitKulkarni23 wants to merge 1 commit into
railwayapp:masterfrom
AmitKulkarni23:fix/mcp-jsonc-utf8
Open

AmitKulkarni23 wants to merge 1 commit into
railwayapp:masterfrom
AmitKulkarni23:fix/mcp-jsonc-utf8

Conversation

@AmitKulkarni23

Copy link
Copy Markdown

The JSONC fallback converts each UTF-8 byte into a separate character, so installing MCP into a commented config changes existing keys and values such as café to café.

Keep the original bytes while stripping comments and trailing commas, then convert the result back to UTF-8. Add regression coverage for Unicode keys and values, escaped strings, line and block comments, and trailing commas. Exercise all seven JSON-based MCP targets with each transport and verify that malformed configs remain unchanged.

Validation on macOS:

  • Both Unicode regressions fail before the fix and pass afterward.
  • cargo test --locked: 1,862 unit tests and 30 integration tests passed; six existing tests ignored. The suite required an unrestricted run because the sandbox blocks ps in the OpenCode lifecycle test.
  • cargo check --locked
  • cargo clippy --locked --all-targets --all-features (existing repository warnings)
  • cargo fmt --all -- --check
  • Ran the reported OpenCode fixture, a strict JSON control, and a block-comment variant through the compiled CLI in disposable homes; existing Unicode entries survived and the Railway entry was installed.

Closes #1312

This branch has not been deployed

No deployments
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.

fix(mcp): preserve UTF-8 keys and values when reading JSONC config

1 participant