{"record":{"id":"2706bd00075d36d9","repo":"jackwener/OpenCLI","slug":"limit-must-be-an-integer-between-1-and-max-lim-2706bd","errorCode":null,"errorMessage":"--limit must be an integer between 1 and ${MAX_LIMIT}","messagePattern":"--limit must be an integer between 1 and (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/device-follow.js","lineNumber":23,"sourceCode":" * to /home; the data is only reachable via the legacy v1.1 REST\n * endpoint `/i/api/2/notifications/device_follow.json`.\n *\n * Endpoint discovery and field-mapping originally proposed by @traddo\n * in issue #1628.\n */\nimport { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { TWITTER_BEARER_TOKEN, applyTopByEngagement } from './utils.js';\nimport { describeTwitterApiError } from './shared.js';\n\nconst DEVICE_FOLLOW_PATH = '/i/api/2/notifications/device_follow.json';\nconst MAX_LIMIT = 200;\n\nfunction parseLimit(value) {\n    if (value === undefined || value === null || value === '') return 20;\n    const limit = Number(value);\n    if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {\n        throw new ArgumentError(`--limit must be an integer between 1 and ${MAX_LIMIT}`);\n    }\n    return limit;\n}\n\nfunction buildDeviceFollowUrl(count) {\n    const params = new URLSearchParams({\n        include_profile_interstitial_type: '1',\n        include_blocking: '1',\n        include_blocked_by: '1',\n        include_followed_by: '1',\n        include_want_retweets: '1',\n        include_mute_edge: '1',\n        include_can_dm: '1',\n        include_can_media_tag: '1',\n        include_ext_has_nft_avatar: '1',\n        include_ext_is_blue_verified: '1',\n        include_ext_verified_type: '1',\n        skip_status: '1',","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/device-follow.js#L5-L41","documentation":"parseLimit validates the user-supplied --limit option before building the device-follow API URL. If the value is not a string-empty/undefined default (20) and cannot be coerced to an integer between 1 and 200 (MAX_LIMIT), an ArgumentError is thrown. This fail-fast guard prevents sending malformed query params to the Twitter API.","triggerScenarios":"Calling the device-follow command with --limit set to a non-numeric string (e.g. --limit abc), a float (e.g. --limit 2.5), a value below 1 (e.g. --limit 0), or a value above MAX_LIMIT=200 (e.g. --limit 500). Note whitespace-only strings and '0x10' style values also fail the integer check.","commonSituations":"Developers scripting the CLI with shell variables that are empty-but-quoted, copying limits from other twitter commands with higher caps (e.g. download.js allows up to 1000), or passing comma-separated lists or values with units like '50 tweets'.","solutions":["Pass an integer between 1 and 200, e.g. --limit 50","Omit --limit entirely to get the default of 20","Trim/validate shell variables before interpolation: --limit \"${N//[!0-9]/}\"","If you need more than 200 items, paginate the command instead of raising the limit"],"exampleFix":"// before\nnode cli twitter device-follow --limit 500\n// after\nnode cli twitter device-follow --limit 200","handlingStrategy":"validation","validationCode":"const n = Number(raw);\nif (raw !== undefined && raw !== null && raw !== '' && (!Number.isInteger(n) || n < 1 || n > 200)) {\n  throw new Error(`--limit must be an integer 1-200, got: ${raw}`);\n}","typeGuard":"function isValidLimit(v) {\n  if (v === undefined || v === null || v === '') return true;\n  const n = Number(v);\n  return Number.isInteger(n) && n >= 1 && n <= 200;\n}","tryCatchPattern":"try {\n  await cli.twitter.deviceFollow({ limit: raw });\n} catch (e) {\n  if (e instanceof ArgumentError) {\n    console.error(`Bad --limit '${raw}': use an integer 1-200`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Validate numeric CLI args at script startup before invoking the command","Never interpolate unquoted or empty shell variables into --limit","Remember the device-follow cap is 200, unlike download's 1000","Default to omitting --limit (20) unless you need more"],"tags":["argument-validation","cli","input-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}