{"record":{"id":"8af84d66bfe60c20","repo":"jackwener/OpenCLI","slug":"timeout-must-be-a-positive-integer-seconds-8af84d","errorCode":null,"errorMessage":"--timeout must be a positive integer (seconds)","messagePattern":"--timeout must be a positive integer \\(seconds\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/ask.js","lineNumber":322,"sourceCode":"    description: 'Send a prompt to Yuanbao web chat and wait for the assistant response',\n    domain: YUANBAO_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    defaultFormat: 'plain',\n    args: [\n        { name: 'prompt', required: true, positional: true, help: 'Prompt to send' },\n        { name: 'timeout', type: 'int', required: false, help: 'Max seconds to wait (default: 60)', default: 60 },\n        { name: 'search', type: 'boolean', required: false, help: 'Enable Yuanbao internet search (default: true)', default: true },\n        { name: 'think', type: 'boolean', required: false, help: 'Enable Yuanbao deep thinking (default: false)', default: false },\n    ],\n    columns: ['Role', 'Text'],\n    func: async (page, kwargs) => {\n        const prompt = kwargs.prompt;\n        const timeout = kwargs.timeout;\n        if (!Number.isInteger(timeout) || timeout < 1) {\n            throw new ArgumentError('--timeout must be a positive integer (seconds)');\n        }\n        const useSearch = normalizeBooleanFlag(kwargs.search, true);\n        const useThink = normalizeBooleanFlag(kwargs.think, false);\n        await ensureYuanbaoPage(page);\n        if (await hasLoginGate(page)) {\n            throw authRequired('Yuanbao opened a login gate before sending the prompt.');\n        }\n        await setYuanbaoInternetSearch(page, useSearch);\n        await setYuanbaoDeepThink(page, useThink);\n        const beforeAssistantMessages = await getYuanbaoAssistantMessages(page);\n        const beforeLines = await getYuanbaoTranscriptLines(page);\n        const sendResult = await sendYuanbaoMessage(page, prompt);\n        if (!sendResult?.ok) {\n            if (await hasLoginGate(page)) {\n                throw authRequired('Yuanbao opened a login gate instead of accepting the prompt.');\n            }\n            throw sendFailure(sendResult?.reason, sendResult?.detail);\n        }","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/ask.js#L304-L340","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a positive integer, e.g. --timeout 60.","Remove unit suffixes ('90s' -> '90') and decimals ('1.5' -> '2').","Default the value in your wrapper before invoking, e.g. timeout = Number(process.env.YB_TIMEOUT ?? 60)."],"exampleFix":"// before\n$ opencli yuanbao ask --timeout 1.5 \"hi\"\nError: --timeout must be a positive integer (seconds)\n// after\n$ opencli yuanbao ask --timeout 2 \"hi\"","handlingStrategy":"validation","validationCode":"const timeout = Number(kwargs.timeout ?? 60);\nif (!Number.isInteger(timeout) || timeout < 1) {\n  throw new Error('--timeout must be a positive integer (seconds)');\n}","typeGuard":"const isValidTimeout = (t) => Number.isInteger(t) && t >= 1;","tryCatchPattern":null,"preventionTips":["Always pass unitless positive integers for --timeout","Provide a default (e.g. 60) in wrapper scripts","Coerce and validate config-file values before passing them through","Reject decimals and unit suffixes at your own CLI boundary"],"tags":["cli","argument-validation","yuanbao"],"backgroundTag":"invalid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}