mirror of
https://github.com/morluto/rea.git
synced 2026-10-31 20:06:14 +00:00
fix(setup): name invalid client config shape errors clearly (#2157)
* fix(setup): name invalid client config shape errors clearly Setup was dumping raw Zod issues for non-object roots or server tables, and uninstall always claimed the file was not valid JSON. Report the structural problem instead, and reserve parse failures for real syntax errors. Fixes #2152 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(setup): preserve client configuration record validation Keep descriptive shape errors while retaining Zod record validation and its own-property copy. Reject tagged YAML objects before setup or uninstall writes and prevent inherited JSONC properties from fabricating client registrations. Add production-boundary regressions for tagged YAML roots and server tables, plus inherited Cursor and OpenCode settings. All 91 focused tests, npm run check, verify:test-discovery, verify:package, and npm pack --dry-run passed. --------- Co-authored-by: Beqa Ksovreli <beqa@Beqas-Macbook-Pro-2.local> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
5 files changed
+213
-31
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseClientConfiguration } from "./ClientConfigurationDocument.js";
|
||||
|
||||
describe("parseClientConfiguration shape diagnostics", () => {
|
||||
it.each([
|
||||
["null", "null"],
|
||||
["array", "[]"],
|
||||
["string", '"x"'],
|
||||
] as const)("names a non-object JSON root (%s)", (_label, text) => {
|
||||
expect(() => parseClientConfiguration(text, "json")).toThrow(
|
||||
new TypeError("The configuration root must be an object"),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["null", "null"],
|
||||
["array", "[]"],
|
||||
["string", '"x"'],
|
||||
] as const)(
|
||||
'names a non-object "mcpServers" value (%s)',
|
||||
(_label, servers) => {
|
||||
expect(() =>
|
||||
parseClientConfiguration(`{"mcpServers":${servers},"keep":1}`, "json"),
|
||||
).toThrow(new TypeError('"mcpServers" must be an object'));
|
||||
},
|
||||
);
|
||||
|
||||
it("still rejects unparsable JSON with SyntaxError", () => {
|
||||
expect(() => parseClientConfiguration("not-json", "json")).toThrow(
|
||||
SyntaxError,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user