{"record":{"id":"c7cb52952c6dfd3c","repo":"jackwener/OpenCLI","slug":"timeout-must-be-a-positive-integer-seconds-c7cb52","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/chatwise/utils.js","lineNumber":9,"sourceCode":"import { ArgumentError } from '@jackwener/opencli/errors';\n\nexport const MESSAGE_WRAPPER_SELECTOR = '[class*=\"group/message\"]';\nexport const MIN_COMPOSER_SCORE = 120;\n\nexport function requirePositiveTimeout(value) {\n    const timeout = value;\n    if (!Number.isInteger(timeout) || timeout <= 0) {\n        throw new ArgumentError('--timeout must be a positive integer (seconds)');\n    }\n    return timeout;\n}\n\nexport function scoreChatwiseComposerCandidate(candidate, viewportHeight = 0) {\n    if (candidate.hidden) return -1000;\n\n    let score = 0;\n    const normalizedRole = String(candidate.role || '').toLowerCase();\n    if (normalizedRole === 'textbox') score += 10;\n\n    const normalizedClasses = `${candidate.classes || ''} ${candidate.editorClasses || ''} ${candidate.ariaLabel || ''}`.toLowerCase();\n    if (normalizedClasses.includes('cm-content')) score += 20;\n    if (normalizedClasses.includes('cm-editor')) score += 30;\n    if (normalizedClasses.includes('simple-editor')) score -= 140;\n\n    const searchableText = `${candidate.placeholder || ''} ${candidate.ariaLabel || ''} ${candidate.text || ''}`.toLowerCase();\n    if (searchableText.includes('enter a message here')) score += 220;","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatwise/utils.js#L1-L27","documentation":"requirePositiveTimeout validates that the --timeout option is an integer greater than zero before it is used to drive page waits in the ChatWise CLI. ArgumentError is thrown when the value is a non-integer or non-positive number, so bad user input fails immediately with a clear message.","triggerScenarios":"Passing --timeout 0, a negative number, a float like 1.5, or a value that was coerced to NaN (e.g. --timeout \"abc\" parsed to a number) into the timeout() helper, which delegates to requirePositiveTimeout.","commonSituations":"Copy-pasting a shell snippet with an empty --timeout value; scripts computing the timeout with arithmetic that yields 0 or NaN; users expecting sub-second timeouts and passing 0.5.","solutions":["Pass a positive whole number of seconds, e.g. --timeout 30.","Check the script or variable feeding --timeout for empty values or non-numeric strings.","If sub-second precision is needed, it is unsupported — use the minimum of 1 second and adjust other waits."],"exampleFix":"// before\nclis chatwise ask \"hi\" --timeout 0.5\n// after\nclis chatwise ask \"hi\" --timeout 5","handlingStrategy":"validation","validationCode":"const n = Number(timeoutArg);\nif (!Number.isInteger(n) || n <= 0) throw new Error('--timeout must be a positive integer (seconds)');","typeGuard":"function isPositiveInt(v) { return Number.isInteger(v) && v > 0; }","tryCatchPattern":"try {\n  runChatwiseAsk({ timeout: parsedTimeout });\n} catch (err) {\n  if (err instanceof ArgumentError) {\n    console.error('Usage: --timeout <positive integer seconds>, e.g. --timeout 60');\n  } else throw err;\n}","preventionTips":["Validate timeout arguments at CLI parse time","Never compute timeouts with arithmetic that can yield 0 or NaN","Document the option as integer seconds in help text"],"tags":["validation","argument-error","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}