{"record":{"id":"869e88dce2192c4c","repo":"jackwener/OpenCLI","slug":"delay-ms-must-be-an-integer-between-0-and-max-de","errorCode":null,"errorMessage":"delay-ms must be an integer between 0 and ${MAX_DELAY_MS}","messagePattern":"delay-ms must be an integer between 0 and (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/follow-batch.js","lineNumber":122,"sourceCode":"\n    if (result.ok) {\n        await page.wait(1);\n    }\n\n    return {\n        username,\n        status: result.ok ? result.status : 'failed',\n        message: result.message,\n    };\n}\n\nexport function parseDelayMs(input) {\n    if (input === undefined || input === null || input === '') {\n        return DEFAULT_DELAY_MS;\n    }\n    const value = Number(input);\n    if (!Number.isInteger(value) || value < 0 || value > MAX_DELAY_MS) {\n        throw new ArgumentError(`delay-ms must be an integer between 0 and ${MAX_DELAY_MS}`);\n    }\n    return value;\n}\n\ncli({\n    site: 'twitter',\n    name: 'follow-batch',\n    access: 'write',\n    description: 'Follow multiple Twitter/X users from a comma-separated username list',\n    domain: 'x.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'usernames', type: 'string', positional: true, required: true, help: 'Comma-separated Twitter/X screen names, with or without @' },\n        { name: 'delay-ms', type: 'int', default: DEFAULT_DELAY_MS, help: 'Delay between follow attempts in milliseconds' },\n    ],\n    columns: ['username', 'status', 'message'],\n    func: async (page, kwargs) => {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/follow-batch.js#L104-L140","documentation":"parseDelayMs validates the `--delay-ms` option and throws ArgumentError unless the value is an integer in [0, 60000]. Omitted, null, or empty-string inputs default to 3000ms; anything non-numeric, non-integer (1.5, '3s'), negative, or above 60000 throws. The cap prevents batch jobs from sleeping unboundedly between follows.","triggerScenarios":"`--delay-ms 2.5` (float); `--delay-ms 100000` (over the 60s MAX_DELAY_MS); `--delay-ms -100` (negative); `--delay-ms abc` or `--delay-ms 3s` (non-numeric/suffixed), so Number.isInteger(value) fails or the range check trips.","commonSituations":"Users expressing seconds instead of milliseconds ('5s' instead of 5000); assuming the cap is higher and setting 120000; NaN produced by a CLI framework when a flag value is missing; floats copy-pasted from config.","solutions":["Pass a whole number of milliseconds between 0 and 60000: `--delay-ms 5000`.","Convert seconds to milliseconds and clamp in scripts: Math.min(Math.max(Math.round(s*1000), 0), 60000).","Omit the flag entirely to use the 3000ms default if no custom pacing is needed.","Coerce with Number() and Number.isInteger() when reading values from config before calling."],"exampleFix":"// before\nopencli twitter follow-batch alice --delay-ms 5s\n// after\nopencli twitter follow-batch alice --delay-ms 5000","handlingStrategy":"validation","validationCode":"function toValidDelayMs(input, { def = 3000, max = 60000 } = {}) {\n  if (input === undefined || input === null || input === '') return def;\n  const v = Number(input);\n  if (!Number.isInteger(v) || v < 0 || v > max) {\n    throw new RangeError(`delay-ms must be an integer between 0 and ${max}, got ${JSON.stringify(input)}`);\n  }\n  return v;\n}","typeGuard":"function isValidDelayMs(v) {\n  return v === undefined || v === null || v === '' ||\n    (Number.isInteger(Number(v)) && Number(v) >= 0 && Number(v) <= 60000);\n}","tryCatchPattern":"try {\n  await followBatch(usernames, { 'delay-ms': rawDelay });\n} catch (e) {\n  if (e.code === 'ARGUMENT' && e.message.includes('delay-ms')) {\n    console.error('Pass whole milliseconds 0-60000, e.g. --delay-ms 5000');\n  } else throw e;\n}","preventionTips":["Express delays in milliseconds, never with 's'/'ms' suffixes.","Clamp and round computed delays: Math.min(Math.max(Math.round(ms), 0), 60000).","Omit the flag to accept the 3000ms default instead of passing 0 by accident.","Validate config-file values with Number.isInteger before passing them through."],"tags":["argument-validation","twitter","cli-usage","range-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}