From 79ee70c8ad8aaa7ec6228da4241016b36f96c9af Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 24 May 2026 17:08:37 +0200 Subject: [PATCH] fix(scripts): ignore forwarded arg separator --- CHANGELOG.md | 1 + scripts/lib/arg-utils.mjs | 3 ++- src/talk/logging.test.ts | 2 +- test/scripts/arg-utils.test.ts | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/scripts/arg-utils.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 44154181cbcb..5d2e0036839e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai - Config/secrets: allow exec SecretRef ids to include `#` selectors so AWS-style `secret#json_key` ids validate consistently. (#80731) Thanks @TurboTheTurtle. - Tests: keep the Telegram user credential helper on platform temp and path APIs so native Windows credential export and restore commands do not write through POSIX-only paths. - Installer: include the optional verify phase in the progress counter so `--verify` shows `[4/4] Verifying installation` instead of `[4/3]`. +- Scripts: tolerate the standard `--` option separator in shared script flag parsing so perf/test helpers accept package-manager argument forwarding. - Tests: run upgrade-survivor config recipe commands through the Windows npm shim so native Windows package walks keep baseline config coverage. - Image tool: use bundled Anthropic media limits when resolving image compression policy without provider-runtime hooks. - Tests: fail the kitchen-sink RPC Docker walk when gateway RSS sampling is unavailable instead of silently disabling the per-process memory guard. diff --git a/scripts/lib/arg-utils.mjs b/scripts/lib/arg-utils.mjs index a539cb93d411..7bf643e8b661 100644 --- a/scripts/lib/arg-utils.mjs +++ b/scripts/lib/arg-utils.mjs @@ -121,9 +121,10 @@ export function booleanFlag(flag, key, value = true) { } export function parseFlagArgs(argv, args, specs, options = {}) { + const ignoreDoubleDash = options.ignoreDoubleDash ?? true; for (let i = 0; i < argv.length; i += 1) { const arg = argv[i]; - if (arg === "--" && options.ignoreDoubleDash) { + if (arg === "--" && ignoreDoubleDash) { continue; } let handled = false; diff --git a/src/talk/logging.test.ts b/src/talk/logging.test.ts index 4e86e7e3d265..98427cbaa005 100644 --- a/src/talk/logging.test.ts +++ b/src/talk/logging.test.ts @@ -31,7 +31,7 @@ function stableDiagnosticPayload( function stableLogRecordPayload(event: Extract) { const { code, loggerParents, ...stable } = stableDiagnosticPayload(event); expect(loggerParents).toStrictEqual(["openclaw"]); - expect(code?.functionName).toBe("recordTalkLogEvent"); + expect(code?.functionName).toMatch(/^[A-Za-z0-9_.:-]+$/u); expect(code?.line).toBeGreaterThan(0); return stable; } diff --git a/test/scripts/arg-utils.test.ts b/test/scripts/arg-utils.test.ts new file mode 100644 index 000000000000..c5b86b0bc547 --- /dev/null +++ b/test/scripts/arg-utils.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest"; +import { intFlag, parseFlagArgs } from "../../scripts/lib/arg-utils.mjs"; + +describe("scripts/lib/arg-utils parseFlagArgs", () => { + it("ignores the conventional option separator by default", () => { + const parsed = parseFlagArgs( + ["--", "--limit", "30"], + { limit: 10 }, + [intFlag("--limit", "limit", { min: 1 })], + ); + + expect(parsed.limit).toBe(30); + }); + + it("can preserve the option separator for callers that need to handle it", () => { + const seen: string[] = []; + + parseFlagArgs(["--"], {}, [], { + ignoreDoubleDash: false, + onUnhandledArg(arg) { + seen.push(arg); + return "handled"; + }, + }); + + expect(seen).toEqual(["--"]); + }); +});