fix(setup): drop non-boolean activation switches from retained entries
A string such as enabled: "false" was kept and then accepted as the desired entry, so setup could report success while doctor rejected the registration. Those values are removed with the other managed switches.
This commit is contained in:
committed by
xeropresence
parent
53ba7e7b31
commit
ff34e7aeff
@@ -66,9 +66,10 @@ Other fields you added to that entry, such as OMP's `timeout` or Codex's
|
||||
client-specific keys. It removes remote-server keys such as `url`, `headers`,
|
||||
`oauth_resource`, and `tcp` that contradict the local command, and an entry-level
|
||||
`enabled: false` or (outside Grok Build) `disabled: true`, so the registration
|
||||
is active. An existing entry without a `command` is a remote server and is
|
||||
replaced whole. A legacy OpenCode entry moved into the native `mcp.servers`
|
||||
table keeps only its environment.
|
||||
is active. A non-boolean `enabled` or `disabled` value is removed too, because
|
||||
registration status accepts only booleans. An existing entry without a
|
||||
`command` is a remote server and is replaced whole. A legacy OpenCode entry
|
||||
moved into the native `mcp.servers` table keeps only its environment.
|
||||
Setup and doctor report a malformed REA environment map or invalid runtime
|
||||
setting before setup writes files. Repair the named setting in the client
|
||||
configuration; setup does not silently discard the rest of the map.
|
||||
|
||||
@@ -1533,8 +1533,11 @@ const REGISTRATION_REMOTE_KEYS: Readonly<Record<string, true>> = {
|
||||
/**
|
||||
* Whether setup replaces or removes an existing entry key. Setup registers an
|
||||
* active server, so entry-level switches that turn it off are removed too.
|
||||
* Grok Build's entry `disabled` is kept, matching registration status, which
|
||||
* reads only Grok's root `disabled_mcp_servers` list.
|
||||
* Non-boolean `enabled` or `disabled` values are removed as well: registration
|
||||
* status requires booleans, and retaining a string would leave doctor invalid
|
||||
* after setup reports success. Grok Build's boolean entry `disabled` is kept,
|
||||
* matching registration status, which reads only Grok's root
|
||||
* `disabled_mcp_servers` list.
|
||||
*/
|
||||
const registrationManagedKey = (
|
||||
dialect: ClientRegistrationDialect,
|
||||
@@ -1543,6 +1546,7 @@ const registrationManagedKey = (
|
||||
): boolean =>
|
||||
Object.hasOwn(REGISTRATION_LAUNCHER_KEYS, key) ||
|
||||
Object.hasOwn(REGISTRATION_REMOTE_KEYS, key) ||
|
||||
((key === "enabled" || key === "disabled") && typeof value !== "boolean") ||
|
||||
(key === "enabled" && value === false) ||
|
||||
(key === "disabled" && value === true && dialect !== "grok");
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ describe("setup workflow", () => {
|
||||
`startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}`,
|
||||
);
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"remote-server keys and switches that turn the server off, which are removed",
|
||||
"non-boolean enabled or disabled values, which are removed",
|
||||
);
|
||||
expect(host.hopperInstalls).toBe(0);
|
||||
expect(host.configurations).toBe(0);
|
||||
@@ -214,7 +214,7 @@ describe("setup approval disclosure", () => {
|
||||
`startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}`,
|
||||
);
|
||||
expect(result.plannedActions[0]?.detail).toContain(
|
||||
"The entry disabled flag is kept.",
|
||||
"A boolean entry disabled flag is kept.",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -338,8 +338,8 @@ const localEntryDisclosure = (clientName: string): string => {
|
||||
: "";
|
||||
const removed =
|
||||
clientName === "grok_build"
|
||||
? "remote-server keys and an enabled: false switch, which are removed. The entry disabled flag is kept."
|
||||
: "remote-server keys and switches that turn the server off, which are removed.";
|
||||
? "remote-server keys, an enabled: false switch, and non-boolean enabled or disabled values, which are removed. A boolean entry disabled flag is kept."
|
||||
: "remote-server keys, switches that turn the server off, and non-boolean enabled or disabled values, which are removed.";
|
||||
const exceptions = rewritten === "" ? removed : `${rewritten}and ${removed}`;
|
||||
return `On an existing local command entry, user fields are kept except ${exceptions} When that entry is remote, its other fields are replaced.`;
|
||||
};
|
||||
|
||||
@@ -138,6 +138,32 @@ it("drops Codex oauth_resource from a local command entry", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("drops malformed activation switches from a local command entry", async () => {
|
||||
const root = await createTestTempDirectory("rea-registration-switches-");
|
||||
const configPath = join(root, "mcp.json");
|
||||
const client: SetupClient = { name: "cursor", format: "json", configPath };
|
||||
const existing = {
|
||||
...clientRegistrationEntry("json", ["rea-old", "mcp"], environment),
|
||||
timeout: 600000,
|
||||
enabled: "false",
|
||||
disabled: "true",
|
||||
};
|
||||
await writeFile(
|
||||
configPath,
|
||||
serializeClientConfiguration(configurationWith("json", existing), "json"),
|
||||
);
|
||||
expect(await configureClientConfiguration(client, {}, command)).toMatchObject(
|
||||
{ status: "configured" },
|
||||
);
|
||||
expect(
|
||||
parseClientConfiguration(await readFile(configPath, "utf8"), "json").servers
|
||||
.rea,
|
||||
).toEqual({
|
||||
...clientRegistrationEntry("json", command, environment),
|
||||
timeout: 600000,
|
||||
});
|
||||
});
|
||||
|
||||
it("drops a Qwen tcp endpoint from a local command entry", async () => {
|
||||
const root = await createTestTempDirectory("rea-registration-tcp-");
|
||||
const configPath = join(root, "settings.json");
|
||||
|
||||
Reference in New Issue
Block a user