{"record":{"id":"eba49986ac2beaee","repo":"jackwener/OpenCLI","slug":"timeout-must-be-a-positive-integer-seconds-eba499","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/codex/ask.js","lineNumber":22,"sourceCode":"export const askCommand = cli({\n    site: 'codex',\n    name: 'ask',\n    access: 'write',\n    description: 'Send a prompt to the current or selected Codex conversation and wait for the AI response',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'text', required: true, positional: true, help: 'Prompt to send' },\n        { name: 'timeout', type: 'int', required: false, help: 'Max seconds to wait for response (default: 60)', default: 60 },\n        ...conversationSelectionArgs,\n    ],\n    columns: ['Role', 'Project', 'Conversation', 'Text'],\n    func: async (page, kwargs) => {\n        const text = kwargs.text;\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 selected = await openCodexConversation(page, kwargs);\n        // Snapshot the current content length before sending\n        const beforeLen = await page.evaluate(`\n      (function() {\n        const turns = document.querySelectorAll('[data-content-search-turn-key]');\n        return turns.length;\n      })()\n    `);\n        // Inject and send\n        const injected = await page.evaluate(`\n      (function(text) {\n        const editables = Array.from(document.querySelectorAll('[contenteditable=\"true\"]'));\n        const composer = editables.length > 0 ? editables[editables.length - 1] : document.querySelector('textarea');\n        if (!composer) return false;\n        composer.focus();\n        document.execCommand('insertText', false, text);\n        return true;","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/codex/ask.js#L4-L40","documentation":"The codex ask command validates its --timeout flag inline before opening a conversation: it must be an integer >= 1 (seconds). Otherwise it throws this ArgumentError, since a zero/negative/NaN timeout cannot bound the response wait meaningfully.","triggerScenarios":"`opencli codex ask --timeout 0`, a negative value, a float, or an unset/empty env-derived value that becomes NaN or 0.","commonSituations":"Treating 0 as 'unlimited', passing milliseconds (60000) expecting seconds semantics is fine but 0.5 or '' is not, config defaults of 0.","solutions":["Pass a positive whole number of seconds, e.g. --timeout 30","Fix env/config defaults so they are integers >= 1","Strip unit suffixes and validate before invoking the CLI"],"exampleFix":"// before\nawait codexAsk({ text: 'hi', timeout: Number(process.env.T || 0) }); // throws\n// after\nawait codexAsk({ text: 'hi', timeout: Number(process.env.T || 30) }); // >= 1","handlingStrategy":"validation","validationCode":"const timeout = Number(process.env.TIMEOUT);\nif (!Number.isInteger(timeout) || timeout < 1) {\n  throw new Error('--timeout must be a positive integer (seconds)');\n}","typeGuard":"function isValidTimeout(v) {\n  return Number.isInteger(v) && v >= 1;\n}","tryCatchPattern":"try {\n  await codexAsk({ text, timeout });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--timeout must be a positive integer')) {\n    console.error('Pass seconds, e.g. --timeout 30');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Default timeouts to a sane positive integer (e.g. 30)","Validate env-derived values with Number.isInteger before passing","Keep units documented (seconds, not milliseconds)","Avoid 0/negative sentinels for timeout flags"],"tags":["validation","argument-error","cli"],"backgroundTag":"invalid-flag-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}