From b77d6149e16e53c4756fa3ded3f2bb5970035d0b Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 22:25:24 +0200 Subject: [PATCH] fix(scripts): reject short flag extension memory values --- scripts/profile-extension-memory.mjs | 4 ++-- test/scripts/profile-extension-memory.test.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/profile-extension-memory.mjs b/scripts/profile-extension-memory.mjs index 3235a84af445..5df74f1c0582 100644 --- a/scripts/profile-extension-memory.mjs +++ b/scripts/profile-extension-memory.mjs @@ -87,7 +87,7 @@ export function parseArgs(argv) { case "--extension": case "-e": { const next = args[index + 1]; - if (!next) { + if (!next || next.startsWith("-")) { throw new Error(`${arg} requires a value`); } options.extensions.push(next); @@ -112,7 +112,7 @@ export function parseArgs(argv) { break; case "--json": { const next = args[index + 1]; - if (!next) { + if (!next || next.startsWith("-")) { throw new Error(`${arg} requires a value`); } options.jsonPath = path.resolve(next); diff --git a/test/scripts/profile-extension-memory.test.ts b/test/scripts/profile-extension-memory.test.ts index f8a6d55d965f..c8e09122493b 100644 --- a/test/scripts/profile-extension-memory.test.ts +++ b/test/scripts/profile-extension-memory.test.ts @@ -103,6 +103,21 @@ describe("scripts/profile-extension-memory", () => { } }); + it("rejects option-looking string flag values before scanning built plugin artifacts", () => { + for (const args of [ + ["--extension", "-h"], + ["--json", "-h"], + ]) { + const result = runProfileExtensionMemory(args); + + expect(result.status).toBe(1); + expect(result.stdout).toBe(""); + expect(result.stderr).toContain(`[extension-memory] ${args[0]} requires a value`); + expect(result.stderr).not.toContain("dist/extensions"); + expect(result.stderr).not.toContain("at "); + } + }); + it("bounds noisy child output without losing RSS samples", () => { const root = mkdtempSync(path.join(tmpdir(), "openclaw-extension-memory-test-")); try {