fix(qa): reject duplicate gauntlet selectors · openclaw/openclaw@5225126
vincentkoc
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -190,6 +190,8 @@ export function parseArgs(argv) {
|
190 | 190 | if (options.qaScenarios.length === 0) { |
191 | 191 | options.qaScenarios = [...DEFAULT_QA_SCENARIOS]; |
192 | 192 | } |
| 193 | +assertNoDuplicateValues(options.pluginIds, "--plugin"); |
| 194 | +assertNoDuplicateValues(options.qaScenarios, "--qa-scenario"); |
193 | 195 | return options; |
194 | 196 | } |
195 | 197 | |
@@ -244,6 +246,20 @@ function normalizeCsv(raw) {
|
244 | 246 | : []; |
245 | 247 | } |
246 | 248 | |
| 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 | + |
247 | 263 | function readOptionalPositiveIntEnv(name) { |
248 | 264 | const raw = process.env[name]; |
249 | 265 | return raw ? parsePositiveInt(raw, name) : undefined; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -131,6 +131,25 @@ describe("plugin gateway gauntlet helpers", () => {
|
131 | 131 | }); |
132 | 132 | }); |
133 | 133 | |
| 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 | + |
134 | 153 | it("rejects valued flags followed by another option", () => { |
135 | 154 | for (const flag of [ |
136 | 155 | "--repo-root", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。