Skip to content

fix(clients): remove a sole JSONC registration with a trailing comma - #4284

Closed
alfredo1491 wants to merge 1 commit into
morluto:mainfrom
alfredo1491:fix/clients-sole-jsonc-trailing-comma
Closed

alfredo1491 wants to merge 1 commit into
morluto:mainfrom
alfredo1491:fix/clients-sole-jsonc-trailing-comma

Conversation

@alfredo1491

Copy link
Copy Markdown
Contributor

Fixes #4244

Problem

When REA's registration is the only member of a JSONC server table and is followed by a trailing comma, rea uninstall fails: Cursor reports failed, the original file is restored, and REA stays registered. Removing the comma by hand makes the same uninstall succeed.

Root cause: for a sole property, deleteJsonPropertyPreservingComments returns undefined and the stock jsonc-parser removal edit runs. That edit (jsonc-parser 3.3.1) drops the property but keeps its trailing comma:

{ "mcpServers": { "rea": {…}, } }   →   { "mcpServers": { , } }

The serialized document then fails validation, so the uninstall transaction rolls back. Tables with another sibling are unaffected (the existing path or the stock edit leaves valid JSONC).

Change

  • deleteJsonPropertyPreservingComments handles the sole-member case: it drops the trailing comma, then applies the same stock removal edit, so the result matches the comma-less file.
  • The whitespace/comment scan that finds the comma is extracted into nextJsoncTokenOffset and shared with the existing next-sibling path; the JSONC edit formatting options are named once (JSONC_EDIT_FORMATTING). No other behavior changes.

Verification

  • New boundary test uninstalls a sole Cursor registration that has a trailing comma in tests/boundary/filesystem/clientConfigurationDialects.test.ts: real configureClientConfiguration registration, a trailing comma added after REA's entry, then systemUninstallHost(...).removeClient(...). It fails on main with expected 'failed' to be 'removed' and passes with this change; the result parses without errors and leaves mcpServers empty.
  • Client configuration suites (tests/boundary/filesystem/client*.test.ts, *ClientConfiguration.test.ts, src/application/{Setup,Uninstall,Client,Doctor}*.test.ts) compared before/after on the same Windows host: identical failure set (46 pre-existing Windows-host failures), 500 → 501 passing, no new failures.
  • tsc --noEmit and oxlint on the changed files: passed.

Unavailable coverage: run on Windows 11 x64 / Node 22.23.1 only; the 46 pre-existing failures in those suites on this host were not investigated, and the full CI suite was not run locally.

🤖 Generated with Claude Code

When REA's entry is the only member of a JSONC server table and is
followed by a trailing comma, jsonc-parser's removal edit drops the
property but keeps the comma, producing `{ , }`. Uninstall then fails
validation, restores the original file, and leaves REA registered
(Cursor reports `failed`).

`deleteJsonPropertyPreservingComments` now handles that sole-member case:
it drops the trailing comma before applying the stock removal edit. The
whitespace/comment scan that locates the comma is shared with the
existing next-sibling path, and the JSONC edit formatting options are
named once.

Fixes morluto#4244

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T23:26:19.321628Z 19f4362 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Fixes uninstall when REA is the only JSONC registration and has a trailing comma.

  • Cursor uninstall removes a sole registration with a trailing comma.

No actionable issues were found. Tests were not run during this review. Whether this PR was superseded could not be checked because GitHub access required authentication.

Reviews (1) · Last reviewed commit: "fix(clients): remove a sole JSONC regist..." · Reviewed by Greptile

morluto added a commit that referenced this pull request Oct 16, 2026
Remove properties and their separators using parsed JSONC token spans. Preserve unrelated comments, BOM, CRLF, backups, and repeated removal behavior.

Refs: #4244, #4284

Co-authored-by: alfredo1491 <[email protected]>
@alfredo1491

Copy link
Copy Markdown
Contributor Author

Closing as superseded: the trailing-comma fix and its test were integrated into main in 4fd28fc, generalized to token-span removal that also preserves comments, BOM, and CRLF. Thanks for the co-authorship credit!

@morluto morluto added area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Cursor uninstall fails when the sole REA server has a trailing comma

2 participants