[PR #2155] [CLOSED] fix: name structural config errors in setup and uninstall #5064

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2155
Author: @chiliec
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix-structural-config-error


📝 Commits (1)

  • 16d204c fix: name structural config errors in setup and uninstall

📊 Changes

4 files changed (+66 additions, -14 deletions)

View changed files

📝 src/application/ClientConfigurationDocument.ts (+26 -6)
📝 src/application/Uninstall.ts (+6 -8)
📝 tests/boundary/filesystem/clientConfigurationBom.test.ts (+14 -0)
📝 tests/boundary/filesystem/clientLifecycle.test.ts (+20 -0)

📄 Description

What

When a client configuration parses but has the wrong shape ({"mcpServers": null}, a JSON array root [], or "mcpServers": "x"), setup and uninstall misdescribe the problem:

  • rea setup interpolates ZodError.message into the remediation — a raw Zod issue dump that never names the offending key.
  • rea uninstall reports Configuration is not valid JSON and was not changed, a parse error that did not happen. The file is valid JSON; the root or mcpServers value simply is not an object.

Fixes #2152.

Fix

parseClientConfiguration (src/application/ClientConfigurationDocument.ts) now validates the root and the servers value through a typed ClientConfigurationStructureError that names what must be an object ("mcpServers" must be an object, the configuration root must be an object) instead of letting objectSchema.parse throw a raw ZodError. uninstall distinguishes that structural error from a true parse failure and reports the named problem; it still says "not valid JSON" only when the text genuinely does not parse. No file is modified in either case, as before.

Tests

Added structural-shape cases to the existing parse and uninstall-preflight suites.

Validation (Node 24.18.0, npm ci):

npx vitest run --project boundary \
  tests/boundary/filesystem/clientConfigurationBom.test.ts \
  tests/boundary/filesystem/clientLifecycle.test.ts
# Test Files  2 passed (2)
#      Tests  68 passed (68)

npx tsc --noEmit        # clean
npx oxfmt --check <changed files>   # all correct format

RED→GREEN confirmed: with the source change stashed, the 4 new assertions fail (setup gets the Zod dump, uninstall reports a false parse error); with the fix applied they pass.


🔄 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/2155 **Author:** [@chiliec](https://github.com/chiliec) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-structural-config-error` --- ### 📝 Commits (1) - [`16d204c`](https://github.com/morluto/rea/commit/16d204cd3ae6111c5502dbe34f41c3873a968066) fix: name structural config errors in setup and uninstall ### 📊 Changes **4 files changed** (+66 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/application/ClientConfigurationDocument.ts` (+26 -6) 📝 `src/application/Uninstall.ts` (+6 -8) 📝 `tests/boundary/filesystem/clientConfigurationBom.test.ts` (+14 -0) 📝 `tests/boundary/filesystem/clientLifecycle.test.ts` (+20 -0) </details> ### 📄 Description ## What When a client configuration parses but has the wrong shape (`{"mcpServers": null}`, a JSON array root `[]`, or `"mcpServers": "x"`), `setup` and `uninstall` misdescribe the problem: - `rea setup` interpolates `ZodError.message` into the remediation — a raw Zod issue dump that never names the offending key. - `rea uninstall` reports `Configuration is not valid JSON and was not changed`, a parse error that did not happen. The file is valid JSON; the root or `mcpServers` value simply is not an object. Fixes #2152. ## Fix `parseClientConfiguration` (`src/application/ClientConfigurationDocument.ts`) now validates the root and the servers value through a typed `ClientConfigurationStructureError` that names what must be an object (`"mcpServers" must be an object`, `the configuration root must be an object`) instead of letting `objectSchema.parse` throw a raw `ZodError`. `uninstall` distinguishes that structural error from a true parse failure and reports the named problem; it still says "not valid JSON" only when the text genuinely does not parse. No file is modified in either case, as before. ## Tests Added structural-shape cases to the existing parse and uninstall-preflight suites. Validation (Node 24.18.0, `npm ci`): ``` npx vitest run --project boundary \ tests/boundary/filesystem/clientConfigurationBom.test.ts \ tests/boundary/filesystem/clientLifecycle.test.ts # Test Files 2 passed (2) # Tests 68 passed (68) npx tsc --noEmit # clean npx oxfmt --check <changed files> # all correct format ``` RED→GREEN confirmed: with the source change stashed, the 4 new assertions fail (setup gets the Zod dump, uninstall reports a false parse error); with the fix applied they pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:02:02 +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#5064
No description provided.