{"record":{"id":"4d73fe91cb23554a","repo":"jackwener/OpenCLI","slug":"invalid-interval-json-stringify-rawvalue-exp","errorCode":null,"errorMessage":"Invalid interval: ${JSON.stringify(rawValue)}. Expected an integer from 0 to ${MAX_INTERVAL_SECONDS}.","messagePattern":"Invalid interval: (.+?)\\. Expected an integer from 0 to (.+?)\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/list-batch-utils.js","lineNumber":42,"sourceCode":"    for (const username of values) {\n        if (!USERNAME_RE.test(username)) {\n            throw new ArgumentError(`Invalid Twitter/X username: ${JSON.stringify(username)}`, example);\n        }\n        const key = username.toLowerCase();\n        if (seen.has(key)) continue;\n        seen.add(key);\n        usernames.push(username);\n    }\n\n    return usernames;\n}\n\nexport function parseBatchIntervalSeconds(rawValue) {\n    const value = rawValue === undefined || rawValue === null || rawValue === ''\n        ? DEFAULT_INTERVAL_SECONDS\n        : Number(rawValue);\n    if (!Number.isInteger(value) || value < 0 || value > MAX_INTERVAL_SECONDS) {\n        throw new ArgumentError(`Invalid interval: ${JSON.stringify(rawValue)}. Expected an integer from 0 to ${MAX_INTERVAL_SECONDS}.`);\n    }\n    return value;\n}\n\nexport function toBatchFailureRow({ listId, username, error }) {\n    return {\n        listId,\n        username,\n        userId: '',\n        status: 'failed',\n        message: error?.message || String(error),\n    };\n}\n\nfunction isGlobalBatchFailure(error) {\n    if (error instanceof ArgumentError || error instanceof AuthRequiredError) {\n        return true;\n    }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/list-batch-utils.js#L24-L60","documentation":"parseBatchIntervalSeconds (the `interval` option of batch commands) converts the raw value to a Number and requires an integer between 0 and MAX_INTERVAL_SECONDS (600). Out-of-range, fractional, or non-numeric values throw ArgumentError quoting the original input; empty/undefined/null defaults to 5 seconds.","triggerScenarios":"Passing --interval with a non-integer (2.5), a non-number (\"fast\"), a negative value (-1), or >600 (700); any of these fail Number.isInteger/range checks after Number() coercion (note Number('fast') is NaN).","commonSituations":"Unit confusion (thinking interval is in milliseconds and passing 5000); typo \"5s\" or \"fast\"; decimal values; empty-ish strings handled fine but 'none' is not; scripts interpolating a bad variable.","solutions":["Pass a plain integer of seconds in 0–600: --interval 30.","Convert milliseconds to seconds in your script (5000 ms → 5).","Omit the flag entirely to use the default of 5 seconds.","Pre-validate: Number.isInteger(Number(v)) && Number(v) >= 0 && Number(v) <= 600."],"exampleFix":"// before\nopencli twitter list-batch-add 123456789 --usernames alice --interval 5000\nArgumentError: Invalid interval: \"5000\". Expected an integer from 0 to 600.\n// after\nopencli twitter list-batch-add 123456789 --usernames alice --interval 5","handlingStrategy":"validation","validationCode":"const n = raw === undefined || raw === '' ? 5 : Number(raw);\nif (!Number.isInteger(n) || n < 0 || n > 600) {\n  throw new Error(`--interval must be an integer of seconds 0-600, got ${JSON.stringify(raw)}`);\n}","typeGuard":"function isValidInterval(v) {\n  const n = v === undefined || v === null || v === '' ? 5 : Number(v);\n  return Number.isInteger(n) && n >= 0 && n <= 600;\n}","tryCatchPattern":"try {\n  await runBatch(argv);\n} catch (e) {\n  if (e instanceof ArgumentError && /Invalid interval/.test(e.message)) {\n    console.error(`${e.message} — interval is seconds, not ms; omit the flag for the 5s default.`);\n    return;\n  }\n  throw e;\n}","preventionTips":["Remember the unit is seconds (0–600), not milliseconds.","Omit --interval to accept the 5-second default.","Use plain integers — no suffixes like '5s' or decimals.","Convert ms→s explicitly in scripts before passing the value."],"tags":["argument-validation","cli","range-check"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}