Skip to content

Commit 5225126

Browse files
committed
fix(qa): reject duplicate gauntlet selectors
1 parent e94deea commit 5225126

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

scripts/check-plugin-gateway-gauntlet.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ export function parseArgs(argv) {
190190
if (options.qaScenarios.length === 0) {
191191
options.qaScenarios = [...DEFAULT_QA_SCENARIOS];
192192
}
193+
assertNoDuplicateValues(options.pluginIds, "--plugin");
194+
assertNoDuplicateValues(options.qaScenarios, "--qa-scenario");
193195
return options;
194196
}
195197

@@ -244,6 +246,20 @@ function normalizeCsv(raw) {
244246
: [];
245247
}
246248

249+
function assertNoDuplicateValues(values, label) {
250+
const seen = new Set();
251+
for (const value of values) {
252+
const normalized = value.trim();
253+
if (!normalized) {
254+
continue;
255+
}
256+
if (seen.has(normalized)) {
257+
throw new Error(`Duplicate ${label} value: ${normalized}`);
258+
}
259+
seen.add(normalized);
260+
}
261+
}
262+
247263
function readOptionalPositiveIntEnv(name) {
248264
const raw = process.env[name];
249265
return raw ? parsePositiveInt(raw, name) : undefined;

test/scripts/plugin-gateway-gauntlet.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,25 @@ describe("plugin gateway gauntlet helpers", () => {
131131
});
132132
});
133133

134+
it("rejects duplicate repeatable selectors", () => {
135+
expect(() => parseArgs(["--plugin", "telegram", "--plugin", "telegram"])).toThrow(
136+
"Duplicate --plugin value: telegram",
137+
);
138+
expect(() =>
139+
parseArgs([
140+
"--qa-scenario",
141+
"channel-chat-baseline",
142+
"--qa-scenario",
143+
"channel-chat-baseline",
144+
]),
145+
).toThrow("Duplicate --qa-scenario value: channel-chat-baseline");
146+
147+
vi.stubEnv("OPENCLAW_PLUGIN_GATEWAY_GAUNTLET_IDS", "telegram,discord");
148+
expect(() => parseArgs(["--plugin", "telegram"])).toThrow(
149+
"Duplicate --plugin value: telegram",
150+
);
151+
});
152+
134153
it("rejects valued flags followed by another option", () => {
135154
for (const flag of [
136155
"--repo-root",

0 commit comments

Comments
 (0)