{"record":{"id":"02d9d60e97c14000","repo":"jackwener/OpenCLI","slug":"timeout-must-be-a-positive-integer","errorCode":null,"errorMessage":"timeout must be a positive integer","messagePattern":"timeout must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/qwen/ask.js","lineNumber":44,"sourceCode":"    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    defaultFormat: 'plain',\n    args: [\n        { name: 'prompt', required: true, positional: true, help: 'Prompt to send to Qianwen' },\n        { name: 'timeout', type: 'int', default: 120, help: 'Max seconds to wait for the response' },\n        { name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },\n        { name: 'think', type: 'boolean', default: false, help: 'Enable 深度思考 (DeepThink)' },\n        { name: 'research', type: 'boolean', default: false, help: 'Enable 深度研究 (DeepResearch)' },\n        { name: 'markdown', type: 'boolean', default: false, help: 'Emit assistant reply as markdown' },\n    ],\n    columns: ['Role', 'Text'],\n    func: async (page, kwargs) => {\n        const prompt = String(kwargs.prompt || '').trim();\n        if (!prompt) throw new ArgumentError('prompt is required');\n        const timeout = Number(kwargs.timeout ?? 120);\n        if (!Number.isInteger(timeout) || timeout <= 0) {\n            throw new ArgumentError('timeout must be a positive integer');\n        }\n        const startFresh = normalizeBooleanFlag(kwargs.new, false);\n        const useThink = normalizeBooleanFlag(kwargs.think, false);\n        const useResearch = normalizeBooleanFlag(kwargs.research, false);\n        const wantMarkdown = normalizeBooleanFlag(kwargs.markdown, false);\n\n        await ensureOnQianwen(page);\n        await dismissLoginModal(page);\n\n        if (startFresh) {\n            await startNewChat(page);\n            await dismissLoginModal(page);\n        }\n\n        if (useThink) await setFeatureToggle(page, 'think', true);\n        if (useResearch) await setFeatureToggle(page, 'research', true);\n\n        // Anchor on the visible transcript BEFORE sending so waitForAnswer can","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/ask.js#L26-L62","documentation":"ArgumentError thrown when the --timeout keyword is not a positive integer. Number(kwargs.timeout ?? 120) is checked with Number.isInteger(timeout) && timeout > 0 before being used for waitForAnswer.","triggerScenarios":"--timeout passed as a non-numeric string, a float (e.g. 2.5), zero, or a negative number.","commonSituations":"Passing '120s' or '2m' instead of seconds; locale-formatted numbers; typo like '--timeout 0'; passing a string with units from a config file.","solutions":["Pass an integer number of seconds, e.g. --timeout 180.","Convert durations in your wrapper script before invoking (2m -> 120).","Default to the built-in 120 by omitting --timeout."],"exampleFix":"// before\nqwen ask --prompt \"hi\" --timeout 2m\n// after\nqwen ask --prompt \"hi\" --timeout 120","handlingStrategy":"validation","validationCode":"const t = Number(process.argv.timeout ?? 120);\nif (!Number.isInteger(t) || t <= 0) { console.error('--timeout must be a positive integer (seconds)'); process.exit(2); }","typeGuard":"function isValidTimeout(v) {\n  const n = Number(v);\n  return Number.isInteger(n) && n > 0;\n}","tryCatchPattern":"try {\n  await qwenAsk(page, { prompt, timeout: t });\n} catch (e) {\n  if (e instanceof ArgumentError && /timeout/.test(e.message)) {\n    console.error('Pass timeout as integer seconds, e.g. --timeout 180');\n  } else { throw e; }\n}","preventionTips":["Always pass timeout as plain integer seconds, no units","Convert '2m'/'90s' style durations in wrapper scripts","Rely on the default (omit --timeout) unless long answers are expected"],"tags":["validation","arguments","timeout"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}