{"record":{"id":"3fd0f4820bc423b9","repo":"jackwener/OpenCLI","slug":"twitter-tweets-limit-must-be-an-integer-between","errorCode":null,"errorMessage":"twitter tweets --limit must be an integer between 1 and ${MAX_TWEETS_LIMIT}","messagePattern":"twitter tweets --limit must be an integer between 1 and (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/tweets.js","lineNumber":87,"sourceCode":"        ) {\n            nextCursor = value.value;\n        }\n        if (Array.isArray(value)) {\n            for (const item of value) visit(item);\n            return;\n        }\n        for (const child of Object.values(value)) {\n            if (child && typeof child === 'object') visit(child);\n        }\n    };\n    visit(instructions);\n    return { tweets, nextCursor };\n}\n\nfunction normalizeLimit(rawLimit) {\n    const limit = rawLimit ?? 20;\n    if (!Number.isInteger(limit) || limit < 1 || limit > MAX_TWEETS_LIMIT) {\n        throw new ArgumentError(\n            `twitter tweets --limit must be an integer between 1 and ${MAX_TWEETS_LIMIT}`,\n            'Example: opencli twitter tweets @jack --limit 250',\n        );\n    }\n    return limit;\n}\n\nfunction normalizePageDelaySeconds(rawDelay) {\n    const delay = rawDelay ?? DEFAULT_PAGE_DELAY_SECONDS;\n    if (!Number.isInteger(delay) || delay < 0 || delay > 60) {\n        throw new ArgumentError(\n            'twitter tweets --page-delay must be an integer between 0 and 60 seconds',\n            'Example: opencli twitter tweets @jack --limit 250 --page-delay 2',\n        );\n    }\n    return delay;\n}\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/tweets.js#L69-L105","documentation":"normalizeLimit in clis/twitter/tweets.js:87 validates the --limit flag for `opencli twitter tweets`. It defaults to 20 and requires an integer within 1..MAX_TWEETS_LIMIT; anything else (float, 0, negative, above the cap, or a non-number like a string) raises ArgumentError telling the valid range. The cap exists to keep pagination bounded and avoid tripping rate limits.","triggerScenarios":"Passing --limit as a non-integer (e.g. --limit 12.5), below 1 (--limit 0 or negative), above MAX_TWEETS_LIMIT, or a non-numeric value that survives flag parsing, when calling `opencli twitter tweets <user>`.","commonSituations":"Typos like --limit 1000 when the cap is lower; scripting that passes floats ('awk' arithmetic or JS division results); passing a string from a wrapper script; copying an example with a limit larger than the current MAX_TWEETS_LIMIT after the cap was lowered in a newer version.","solutions":["Run with an integer between 1 and the documented MAX_TWEETS_LIMIT (the message states the current max), e.g. --limit 250","Floor/round computed values before passing: Math.floor(Number(raw)) and re-check the range","Check the CLI version for the current cap — MAX_TWEETS_LIMIT may have changed; clamp your default accordingly","In wrapper scripts, validate the flag value before invoking the CLI"],"exampleFix":"// before\nopencli twitter tweets @jack --limit 12.5\n// after\nopencli twitter tweets @jack --limit 12","handlingStrategy":"validation","validationCode":"const MAX_TWEETS_LIMIT = 250; // match the library's current cap\nfunction assertLimit(v) {\n  const n = Number(v);\n  if (!Number.isInteger(n) || n < 1 || n > MAX_TWEETS_LIMIT) {\n    throw new Error(`--limit must be an integer 1..${MAX_TWEETS_LIMIT}`);\n  }\n  return n;\n}","typeGuard":"function isValidLimit(v) {\n  return Number.isInteger(v) && v >= 1 && v <= 250;\n}","tryCatchPattern":"import { ArgumentError } from '@jackwener/opencli/errors';\ntry {\n  await run(['twitter', 'tweets', '@jack', '--limit', String(myLimit)]);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--limit')) {\n    console.error('Fix --limit: integer between 1 and the documented max.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Sanitize user/script input with Math.floor(Number(v)) before passing --limit","Clamp to the documented MAX_TWEETS_LIMIT in wrapper scripts","Re-check the cap after upgrading the CLI (limits can change between versions)","Add shell-level validation in automation that constructs CLI invocations"],"tags":["argument-validation","cli-flag","input-validation","twitter"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}