mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 09:54:09 +00:00
fix(cli): reject malformed timeout values
This commit is contained in:
@@ -106,6 +106,7 @@ import {
|
||||
getModelsCommandSecretTargetIds,
|
||||
getTtsCommandSecretTargetIds,
|
||||
} from "./command-secret-targets.js";
|
||||
import { parseTimeoutMsWithFallback } from "./parse-timeout.js";
|
||||
import { removeCommandByName } from "./program/command-tree.js";
|
||||
import { collectOption } from "./program/helpers.js";
|
||||
|
||||
@@ -1179,6 +1180,13 @@ function parseOptionalPositiveInteger(raw: unknown, label: string): number | und
|
||||
return value;
|
||||
}
|
||||
|
||||
function parseOptionalTimeoutMs(raw: string | number | undefined): number | undefined {
|
||||
if (raw === undefined || (typeof raw === "string" && raw.trim() === "")) {
|
||||
return undefined;
|
||||
}
|
||||
return parseTimeoutMsWithFallback(raw, 0, { invalidType: "error" });
|
||||
}
|
||||
|
||||
function normalizeImageOutputFormat(
|
||||
raw: string | undefined,
|
||||
): ImageGenerationOutputFormat | undefined {
|
||||
@@ -1961,7 +1969,7 @@ export function registerCapabilityCli(program: Command) {
|
||||
opts.openaiBackground as string | undefined,
|
||||
"--openai-background",
|
||||
),
|
||||
timeoutMs: parseOptionalFiniteNumber(opts.timeoutMs, "--timeout-ms"),
|
||||
timeoutMs: parseOptionalTimeoutMs(opts.timeoutMs),
|
||||
output: opts.output as string | undefined,
|
||||
});
|
||||
emitJsonOrText(defaultRuntime, Boolean(opts.json), result, formatEnvelopeForText);
|
||||
@@ -2000,7 +2008,7 @@ export function registerCapabilityCli(program: Command) {
|
||||
opts.openaiBackground as string | undefined,
|
||||
"--openai-background",
|
||||
),
|
||||
timeoutMs: parseOptionalFiniteNumber(opts.timeoutMs, "--timeout-ms"),
|
||||
timeoutMs: parseOptionalTimeoutMs(opts.timeoutMs),
|
||||
output: opts.output as string | undefined,
|
||||
});
|
||||
emitJsonOrText(defaultRuntime, Boolean(opts.json), result, formatEnvelopeForText);
|
||||
@@ -2022,7 +2030,7 @@ export function registerCapabilityCli(program: Command) {
|
||||
files: [String(opts.file)],
|
||||
model: opts.model as string | undefined,
|
||||
prompt: opts.prompt as string | undefined,
|
||||
timeoutMs: parseOptionalFiniteNumber(opts.timeoutMs, "--timeout-ms"),
|
||||
timeoutMs: parseOptionalTimeoutMs(opts.timeoutMs),
|
||||
});
|
||||
emitJsonOrText(defaultRuntime, Boolean(opts.json), result, formatEnvelopeForText);
|
||||
});
|
||||
@@ -2043,7 +2051,7 @@ export function registerCapabilityCli(program: Command) {
|
||||
files: opts.file as string[],
|
||||
model: opts.model as string | undefined,
|
||||
prompt: opts.prompt as string | undefined,
|
||||
timeoutMs: parseOptionalFiniteNumber(opts.timeoutMs, "--timeout-ms"),
|
||||
timeoutMs: parseOptionalTimeoutMs(opts.timeoutMs),
|
||||
});
|
||||
emitJsonOrText(defaultRuntime, Boolean(opts.json), result, formatEnvelopeForText);
|
||||
});
|
||||
@@ -2352,7 +2360,7 @@ export function registerCapabilityCli(program: Command) {
|
||||
durationSeconds: parseOptionalFiniteNumber(opts.duration, "--duration"),
|
||||
audio: opts.audio === true ? true : undefined,
|
||||
watermark: opts.watermark === true ? true : undefined,
|
||||
timeoutMs: parseOptionalFiniteNumber(opts.timeoutMs, "--timeout-ms"),
|
||||
timeoutMs: parseOptionalTimeoutMs(opts.timeoutMs),
|
||||
});
|
||||
emitJsonOrText(defaultRuntime, Boolean(opts.json), result, formatEnvelopeForText);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user