[PR #2154] [MERGED] fix(setup): name structural problems in client configurations #5063

Closed
opened 2026-10-31 01:01:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2154
Author: @kaoru0822-kitauji
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/issue-2152


📝 Commits (1)

  • 49f9360 fix(setup): name structural problems in client configurations

📊 Changes

3 files changed (+61 additions, -5 deletions)

View changed files

📝 src/application/ClientConfigurationDocument.ts (+28 -3)
📝 src/application/Uninstall.ts (+4 -2)
📝 tests/boundary/filesystem/clientLifecycle.test.ts (+29 -0)

📄 Description

Summary

Some client configurations parse fine but have the wrong shape: {"mcpServers": null}, "mcpServers": "x", a JSON array root [], or mcp_servers = 5 in Codex TOML. For these:

  • rea setup reported the raw Zod issue list as the malformed detail. It did not name the key ("path": [], "expected": "record").
  • rea uninstall reported Configuration is not valid JSON and was not changed, although the file is valid JSON.

parseClientConfiguration now raises ClientConfigurationShapeError for these cases: "<serversKey>" must be an object, "mcp.servers" must be an object for OpenCode V2, or The configuration root must be an object.

  • Setup's malformed detail carries that message.
  • Uninstall uses it (Configuration was not changed: "mcpServers" must be an object. Repair it, then rerun uninstall.). The "not valid JSON/TOML/JSONC" wording is kept for genuine parse failures.

Nothing changes about what is written: these files are still refused unchanged, with no backup.

parseDocument is left untouched, so this does not conflict with #2096. The root-shape ZodError it raises is translated at the parseClientConfiguration boundary.

Fixes #2152

Before / after (isolated HOME, ~/.cursor/mcp.json = {"mcpServers": null, "keep": 1})

setup   before: …/mcp.json is malformed: [ { "expected": "record", "code": "invalid_type", "path": [], "message": "Invalid input: expected record, received null" } ]
setup   after:  …/mcp.json is malformed: "mcpServers" must be an object
uninstall before: Configuration is not valid JSON and was not changed. Repair it, then rerun uninstall.
uninstall after:  Configuration was not changed: "mcpServers" must be an object. Repair it, then rerun uninstall.

An unparseable file ({"mcpServers": {) still reports Invalid JSON/JSONC at offset … in setup and not valid JSON in uninstall.

Validation

  • New cases in tests/boundary/filesystem/clientLifecycle.test.ts cover {"mcpServers": null} and []. Each checks the readConfigurationFile malformed detail, the uninstall item detail, and that the file is unchanged. They fail on main and pass with this change; all 50 tests in the file pass.
  • npm run lint passes.
  • npm test: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on clean origin/main on this host: Hopper not installed, Command Line Tools only (ibtool), hdiutil, and inspector target-location cases.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2154 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/issue-2152` --- ### 📝 Commits (1) - [`49f9360`](https://github.com/morluto/rea/commit/49f936084361e897b9e244dfb290f506225b2991) fix(setup): name structural problems in client configurations ### 📊 Changes **3 files changed** (+61 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/application/ClientConfigurationDocument.ts` (+28 -3) 📝 `src/application/Uninstall.ts` (+4 -2) 📝 `tests/boundary/filesystem/clientLifecycle.test.ts` (+29 -0) </details> ### 📄 Description ## Summary Some client configurations parse fine but have the wrong shape: `{"mcpServers": null}`, `"mcpServers": "x"`, a JSON array root `[]`, or `mcp_servers = 5` in Codex TOML. For these: - `rea setup` reported the raw Zod issue list as the malformed detail. It did not name the key (`"path": []`, `"expected": "record"`). - `rea uninstall` reported `Configuration is not valid JSON and was not changed`, although the file is valid JSON. `parseClientConfiguration` now raises `ClientConfigurationShapeError` for these cases: `"<serversKey>" must be an object`, `"mcp.servers" must be an object` for OpenCode V2, or `The configuration root must be an object`. - Setup's malformed detail carries that message. - Uninstall uses it (`Configuration was not changed: "mcpServers" must be an object. Repair it, then rerun uninstall.`). The "not valid JSON/TOML/JSONC" wording is kept for genuine parse failures. Nothing changes about what is written: these files are still refused unchanged, with no backup. `parseDocument` is left untouched, so this does not conflict with #2096. The root-shape `ZodError` it raises is translated at the `parseClientConfiguration` boundary. Fixes #2152 ## Before / after (isolated HOME, `~/.cursor/mcp.json` = `{"mcpServers": null, "keep": 1}`) ```text setup before: …/mcp.json is malformed: [ { "expected": "record", "code": "invalid_type", "path": [], "message": "Invalid input: expected record, received null" } ] setup after: …/mcp.json is malformed: "mcpServers" must be an object uninstall before: Configuration is not valid JSON and was not changed. Repair it, then rerun uninstall. uninstall after: Configuration was not changed: "mcpServers" must be an object. Repair it, then rerun uninstall. ``` An unparseable file (`{"mcpServers": {`) still reports `Invalid JSON/JSONC at offset …` in setup and `not valid JSON` in uninstall. ## Validation - New cases in `tests/boundary/filesystem/clientLifecycle.test.ts` cover `{"mcpServers": null}` and `[]`. Each checks the `readConfigurationFile` malformed detail, the uninstall item detail, and that the file is unchanged. They fail on main and pass with this change; all 50 tests in the file pass. - `npm run lint` passes. - `npm test`: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on clean `origin/main` on this host: Hopper not installed, Command Line Tools only (`ibtool`), `hdiutil`, and inspector target-location cases. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:01:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5063
No description provided.