jackwener/OpenCLI · error · ArgumentError

--timeout must be a positive integer (seconds)

Error message

--timeout must be a positive integer (seconds)

What it means

An ArgumentError thrown by the `yuanbao ask` command when the --timeout option is not an integer >= 1 (seconds). The command validates kwargs.timeout before doing any browser work so a bad flag value fails fast instead of hanging or misconfiguring waitForYuanbaoResponse. Non-integer, zero, negative, or missing/NaN values all trigger it.

Source

Thrown at clis/yuanbao/ask.js:322

    description: 'Send a prompt to Yuanbao web chat and wait for the assistant response',
    domain: YUANBAO_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    defaultFormat: 'plain',
    args: [
        { name: 'prompt', required: true, positional: true, help: 'Prompt to send' },
        { name: 'timeout', type: 'int', required: false, help: 'Max seconds to wait (default: 60)', default: 60 },
        { name: 'search', type: 'boolean', required: false, help: 'Enable Yuanbao internet search (default: true)', default: true },
        { name: 'think', type: 'boolean', required: false, help: 'Enable Yuanbao deep thinking (default: false)', default: false },
    ],
    columns: ['Role', 'Text'],
    func: async (page, kwargs) => {
        const prompt = kwargs.prompt;
        const timeout = kwargs.timeout;
        if (!Number.isInteger(timeout) || timeout < 1) {
            throw new ArgumentError('--timeout must be a positive integer (seconds)');
        }
        const useSearch = normalizeBooleanFlag(kwargs.search, true);
        const useThink = normalizeBooleanFlag(kwargs.think, false);
        await ensureYuanbaoPage(page);
        if (await hasLoginGate(page)) {
            throw authRequired('Yuanbao opened a login gate before sending the prompt.');
        }
        await setYuanbaoInternetSearch(page, useSearch);
        await setYuanbaoDeepThink(page, useThink);
        const beforeAssistantMessages = await getYuanbaoAssistantMessages(page);
        const beforeLines = await getYuanbaoTranscriptLines(page);
        const sendResult = await sendYuanbaoMessage(page, prompt);
        if (!sendResult?.ok) {
            if (await hasLoginGate(page)) {
                throw authRequired('Yuanbao opened a login gate instead of accepting the prompt.');
            }
            throw sendFailure(sendResult?.reason, sendResult?.detail);
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a positive integer, e.g. --timeout 60.
  2. Remove unit suffixes ('90s' -> '90') and decimals ('1.5' -> '2').
  3. Default the value in your wrapper before invoking, e.g. timeout = Number(process.env.YB_TIMEOUT ?? 60).

Example fix

// before
$ opencli yuanbao ask --timeout 1.5 "hi"
Error: --timeout must be a positive integer (seconds)
// after
$ opencli yuanbao ask --timeout 2 "hi"
Defensive patterns

Strategy: validation

Validate before calling

const timeout = Number(kwargs.timeout ?? 60);
if (!Number.isInteger(timeout) || timeout < 1) {
  throw new Error('--timeout must be a positive integer (seconds)');
}

Type guard

const isValidTimeout = (t) => Number.isInteger(t) && t >= 1;

Prevention

When it happens

Trigger: Running `yuanbao ask` with --timeout set to 0, a negative number, a float like 1.5, a non-numeric string that was not coerced, or omitting it entirely so it arrives undefined/NaN.

Common situations: Typing `--timeout 90s` or `--timeout 1.5` expecting lenient parsing; forgetting the flag when a wrapper doesn't supply a default; passing a string from a config file.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/8af84d66bfe60c20. Report an issue: GitHub.