mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-11 07:29:00 +02:00
fix(benchmark): validate --timeout-ms as a positive integer
gstack-model-benchmark fed --timeout-ms straight through parseInt, so "abc" became NaN and "0"/"-1" passed through — a NaN or non-positive timeout silently disables the per-provider watchdog. Reject anything that isn't a positive (optionally +-prefixed) safe integer with a clear error and exit 1. Closes #1726. Contributed by @jbetala7 (PR #1727). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
36c608eb6e
commit
be671e80cc
@@ -88,6 +88,20 @@ function parseProviders(s: string | undefined): Array<'claude' | 'gpt' | 'gemini
|
||||
return seen.size ? Array.from(seen) : ['claude'];
|
||||
}
|
||||
|
||||
function parsePositiveIntegerFlag(name: string, def: string): number {
|
||||
const raw = arg(name, def);
|
||||
if (!raw || !/^\+?[1-9]\d*$/.test(raw)) {
|
||||
console.error(`${name} requires a positive integer`);
|
||||
process.exit(1);
|
||||
}
|
||||
const parsed = Number(raw);
|
||||
if (!Number.isSafeInteger(parsed)) {
|
||||
console.error(`${name} requires a positive integer`);
|
||||
process.exit(1);
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function resolvePrompt(positional: string | undefined): string {
|
||||
const inline = arg('--prompt');
|
||||
if (inline) return inline;
|
||||
@@ -107,7 +121,7 @@ async function main(): Promise<void> {
|
||||
const prompt = resolvePrompt(positional);
|
||||
const providers = parseProviders(arg('--models'));
|
||||
const workdir = arg('--workdir', process.cwd())!;
|
||||
const timeoutMs = parseInt(arg('--timeout-ms', '300000')!, 10);
|
||||
const timeoutMs = parsePositiveIntegerFlag('--timeout-ms', '300000');
|
||||
const output = (arg('--output', 'table') as OutputFormat);
|
||||
const skipUnavailable = flag('--skip-unavailable');
|
||||
const doJudge = flag('--judge');
|
||||
|
||||
Reference in New Issue
Block a user