From 75b8a9f9ebcd55d3e56cf9d1d112e03c0f347e61 Mon Sep 17 00:00:00 2001 From: gensokyo-dev Date: Thu, 3 Dec 2026 03:47:49 +0000 Subject: [PATCH] fix(config): leave environment WABT directory admission to the WASM lane A relative REA_WABT_BIN_DIRECTORY in the environment made the whole REA configuration invalid, disabling unrelated tools, instead of returning the WASM provider's directory_not_absolute diagnostic. Validate the saved value in the user configuration owner beside REA_JADX_MCP_JAR, which follows the same rule. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --- src/config/environment.ts | 5 ----- src/config/userConfig.ts | 24 +++++++++++++++++++----- tests/boundary/userConfig.test.ts | 19 ++++++++++++++++--- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/config/environment.ts b/src/config/environment.ts index f9cde30b92e..3de5b959219 100644 --- a/src/config/environment.ts +++ b/src/config/environment.ts @@ -112,11 +112,6 @@ const environmentSchema = z.object({ .min(1) .refine(isAbsolute, "REA_ILSPY_CMD_PATH must be absolute") .optional(), - REA_WABT_BIN_DIRECTORY: z - .string() - .min(1) - .refine(isAbsolute, "REA_WABT_BIN_DIRECTORY must be absolute") - .optional(), HOPPER_LAUNCHER_PATH: z.string().min(1).optional(), HOPPER_TARGET_PATH: z.string().min(1).optional(), HOPPER_TARGET_KIND: z.enum(["executable", "database"]).default("executable"), diff --git a/src/config/userConfig.ts b/src/config/userConfig.ts index 60e3d1f0873..0f588384738 100644 --- a/src/config/userConfig.ts +++ b/src/config/userConfig.ts @@ -27,6 +27,16 @@ export const PERSISTED_SETTINGS = [ ] as const; export type PersistedSetting = (typeof PERSISTED_SETTINGS)[number]; + +/** + * Absolute paths whose environment value the owning provider admits, so a + * relative value there fails only that provider's lane. A saved value is + * still refused before it is written. + */ +const PROVIDER_OWNED_ABSOLUTE_SETTINGS = [ + "REA_JADX_MCP_JAR", + "REA_WABT_BIN_DIRECTORY", +] as const satisfies readonly PersistedSetting[]; export type UserSettings = Partial>; type RawUserConfig = Partial>; @@ -79,13 +89,17 @@ export const parseUserConfig = ( } const native = parseEnvironmentValues(parsed); if (!native.ok) return native; - const jadx = parsed.REA_JADX_MCP_JAR; - if (jadx !== undefined && !isAbsolute(jadx)) + const relative = PROVIDER_OWNED_ABSOLUTE_SETTINGS.filter((setting) => { + const value = parsed[setting]; + return value !== undefined && !isAbsolute(value); + }); + if (relative.length > 0) return err( new ConfigurationError("Invalid REA user configuration", { - settings: [ - { setting: "REA_JADX_MCP_JAR", constraint: "must be absolute" }, - ], + settings: relative.map((setting) => ({ + setting, + constraint: "must be absolute", + })), }), ); return ok(parsed); diff --git a/tests/boundary/userConfig.test.ts b/tests/boundary/userConfig.test.ts index 8d41e997b0d..fa46b69c29a 100644 --- a/tests/boundary/userConfig.test.ts +++ b/tests/boundary/userConfig.test.ts @@ -12,6 +12,7 @@ import { join, posix, win32 } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; +import { parseConfig } from "../../src/config/parseConfig.js"; import { applyUserConfigurationDefaults, parseUserConfig, @@ -84,9 +85,21 @@ describe("parseUserConfig", () => { }); }); - it("rejects a relative REA_WABT_BIN_DIRECTORY the same way the environment schema does", () => { - const parsed = parseUserConfig({ REA_WABT_BIN_DIRECTORY: "wabt/bin" }); - expect(parsed.ok).toBe(false); + it("refuses to save a relative REA_WABT_BIN_DIRECTORY that the WASM lane leaves to its own admission", () => { + expect(parseUserConfig({ REA_WABT_BIN_DIRECTORY: "wabt/bin" })).toEqual({ + ok: false, + error: expect.objectContaining({ + settings: [ + { + setting: "REA_WABT_BIN_DIRECTORY", + constraint: "must be absolute", + }, + ], + }), + }); + // The environment value stays with the WASM provider, whose + // directory_not_absolute diagnostic does not disable unrelated tools. + expect(parseConfig({ REA_WABT_BIN_DIRECTORY: "wabt/bin" }).ok).toBe(true); }); it("rejects non-string values", () => {