From f9560e5bac403a4dc09bc6f0d5e0195d495257d3 Mon Sep 17 00:00:00 2001 From: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com> Date: Sun, 6 Sep 2026 17:21:06 +0800 Subject: [PATCH] fix(installer): report the requested unsupported platform --- mcp-package/bin/fetch-engine.js | 5 +++-- mcp-package/test/fetch-engine.test.js | 28 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/mcp-package/bin/fetch-engine.js b/mcp-package/bin/fetch-engine.js index d8ba0f1..4290181 100644 --- a/mcp-package/bin/fetch-engine.js +++ b/mcp-package/bin/fetch-engine.js @@ -387,9 +387,10 @@ function isStale(targetDir, version) { * and which assets were downloaded (empty when everything was already there). */ async function ensureEngine(version, targetDir, options = {}) { - const assets = requiredAssets(options.platform, options.arch); + const { platform = os.platform(), arch = os.arch() } = options; + const assets = requiredAssets(platform, arch); if (assets.length === 0) { - throw new Error(`no CodeGraph engine is published for ${os.platform()}-${os.arch()}`); + throw new Error(`no CodeGraph engine is published for ${platform}-${arch}`); } fs.mkdirSync(targetDir, { recursive: true }); diff --git a/mcp-package/test/fetch-engine.test.js b/mcp-package/test/fetch-engine.test.js index f1cfe91..9d7f881 100644 --- a/mcp-package/test/fetch-engine.test.js +++ b/mcp-package/test/fetch-engine.test.js @@ -474,6 +474,34 @@ async function run() { // someone else's binary. check(platformBinaryName("linux", "riscv64") === null, "an unbuilt arch resolves to nothing"); check(requiredAssets("linux", "riscv64").length === 0, "an unpublished pair needs no assets"); + + // --- unsupported installs report the requested platform and arch ----- + { + const dir = scratch(); + const targetDir = path.join(dir, "engine"); + const { server, baseUrl } = await startRelease({}); + try { + for (const [options, target] of [ + [{ platform: "freebsd", arch: "x64" }, "freebsd-x64"], + [{ platform: "linux", arch: "riscv64" }, "linux-riscv64"], + [{ platform: "win32", arch: "arm" }, "win32-arm"], + [{ platform: "freebsd" }, `freebsd-${os.arch()}`], + [{ arch: "riscv64" }, `${os.platform()}-riscv64`], + ]) { + let threw = null; + await ensureEngine(VERSION, targetDir, { ...options, baseUrl }).catch((e) => (threw = e)); + check( + threw !== null && threw.message === `no CodeGraph engine is published for ${target}`, + `an unsupported install reports ${target}` + ); + check(!fs.existsSync(targetDir), `${target} is rejected before creating the install directory`); + } + } finally { + server.close(); + fs.rmSync(dir, { recursive: true, force: true }); + } + } + // Every name the mapping can return has to be a name the release publishes, // or an install fetches a 404. for (const [p, a] of [