{"record":{"id":"e8281d817c29ceaf","repo":"jackwener/OpenCLI","slug":"twitter-collection-limit-must-be-an-integer-betw","errorCode":null,"errorMessage":"twitter collection --limit must be an integer between 1 and ${MAX_USER_TWEETS_LIMIT}","messagePattern":"twitter collection --limit must be an integer between 1 and (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/collection.js","lineNumber":69,"sourceCode":"        throw new ArgumentError(\n            'twitter collection --until must be an RFC3339 timestamp',\n            'Example: opencli twitter collection @jack --until 2026-07-23T00:00:00Z',\n        );\n    }\n    const parsed = new Date(value);\n    if (Number.isNaN(parsed.getTime())) {\n        throw new ArgumentError(\n            'twitter collection --until must be an RFC3339 timestamp',\n            'Example: opencli twitter collection @jack --until 2026-07-23T00:00:00Z',\n        );\n    }\n    return parsed;\n}\n\nfunction normalizeCollectionLimit(rawLimit) {\n    const limit = rawLimit ?? MAX_USER_TWEETS_LIMIT;\n    if (!Number.isInteger(limit) || limit < 1 || limit > MAX_USER_TWEETS_LIMIT) {\n        throw new ArgumentError(\n            `twitter collection --limit must be an integer between 1 and ${MAX_USER_TWEETS_LIMIT}`,\n            'Example: opencli twitter collection @jack --until 2026-07-23T00:00:00Z --limit 250',\n        );\n    }\n    return limit;\n}\n\nfunction normalizeCollectionPageDelaySeconds(rawDelay) {\n    const delay = rawDelay ?? DEFAULT_USER_TWEETS_PAGE_DELAY_SECONDS;\n    if (!Number.isInteger(delay) || delay < 0 || delay > 60) {\n        throw new ArgumentError(\n            'twitter collection --page-delay must be an integer between 0 and 60 seconds',\n            'Example: opencli twitter collection @jack --until 2026-07-23T00:00:00Z --page-delay 2',\n        );\n    }\n    return delay;\n}\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/collection.js#L51-L87","documentation":"normalizeCollectionLimit enforces that --limit is an integer within [1, MAX_USER_TWEETS_LIMIT]; non-integers, zero, negatives, or values above the cap throw with the allowed range interpolated. When the flag is omitted, the default MAX_USER_TWEETS_LIMIT is used silently.","triggerScenarios":"opencli twitter collection --limit 0, --limit -5, --limit 12.5, --limit 100000 (above MAX_USER_TWEETS_LIMIT), or a shell passing '250\\n'/unquoted garbage that isn't an integer after ?? defaulting.","commonSituations":"Assuming the cap is unlimited or a different number; typo'd values like 1ooo; scripts passing string values (Number.isInteger('250') is false); copying a --limit from a different subcommand with a different max.","solutions":["Pass a plain integer between 1 and MAX_USER_TWEETS_LIMIT (see error message for the cap)","Omit --limit entirely to use the default maximum","Ensure scripts pass numbers, not strings (cast with Number.parseInt first)","Check the CLI docs/help for the current max if you need more tweets — paginate with --until instead"],"exampleFix":"// before\n--limit 0\n// after\n--limit 250","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 1000; // check CLI help for actual cap\nfunction validateLimit(n) {\n  return Number.isInteger(n) && n >= 1 && n <= MAX_LIMIT;\n}\nif (!validateLimit(limit)) throw new Error(`--limit must be an integer in [1, ${MAX_LIMIT}]`);","typeGuard":"function isValidLimit(v) {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 1;\n}","tryCatchPattern":"try {\n  await run(['opencli','twitter','collection',handle,'--limit',String(limit)]);\n} catch (err) {\n  if (String(err.message).startsWith('twitter collection --limit must be an integer')) {\n    limit = 250; // fall back to documented example value\n  } else throw err;\n}","preventionTips":["Always String()-coerce numbers when building CLI args in scripts","Never pass strings, floats, or 0 as --limit","Omit --limit to accept the default maximum instead of guessing the cap","Paginate with --until for volumes above the max rather than raising the limit"],"tags":["twitter","cli","validation","limit"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}