{"record":{"id":"650dfa5509035238","repo":"jackwener/OpenCLI","slug":"limit-must-be-an-integer-between-1-and-max-lim-650dfa","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/linkedin/people-search.js","lineNumber":24,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { looksLinkedInAuthWall, normalizeWhitespace, unwrapEvaluateResult } from './shared.js';\n\nconst LINKEDIN_DOMAIN = 'www.linkedin.com';\nconst SEARCH_URL_BASE = 'https://www.linkedin.com/search/results/people/';\nconst MAX_LIMIT = 10;\n\nfunction requireStringArg(args, key, label = key) {\n    const value = normalizeWhitespace(args[key]);\n    if (!value) throw new ArgumentError(`${label} is required`);\n    return value;\n}\n\nfunction parseLimit(value) {\n    if (value === undefined || value === null || value === '') return 5;\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 buildSearchUrl(keywords) {\n    return SEARCH_URL_BASE + '?keywords=' + encodeURIComponent(keywords);\n}\n\nfunction normalizeProfileUrl(value) {\n    const raw = normalizeWhitespace(value);\n    if (!raw) return '';\n    try {\n        const parsed = new URL(raw);\n        const host = parsed.hostname.toLowerCase();\n        if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port) return '';\n        if (host !== 'linkedin.com' && host !== 'www.linkedin.com') return '';\n        const match = parsed.pathname.match(/^\\/in\\/([^/?#]+)\\/?$/);\n        if (!match || !match[1]) return '';","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/people-search.js#L6-L42","documentation":"ArgumentError thrown by parseLimit when the --limit value is not an integer between 1 and MAX_LIMIT (10). The function defaults to 5 when the value is absent but rejects any present value that fails Number conversion or range/integer checks.","triggerScenarios":"Passing --limit 0, --limit 11, --limit abc, --limit 2.5, or a value like '1e3' that fails the integer/1..MAX_LIMIT check.","commonSituations":"Typing an out-of-range limit; passing a float or comma-formatted number ('1,000'); an older script using a limit above the library's new cap of 10 after a version change.","solutions":["Pass an integer between 1 and 10: --limit 10","Clamp the value before invoking: Math.min(10, Math.max(1, parseInt(value, 10)))","Remove commas/units from numeric input before passing","Update scripts that relied on limits above 10 — MAX_LIMIT is hard-capped at 10"],"exampleFix":"// before\nconst limit = userSuppliedLimit; // e.g. 25\nawait runCli(['people-search', '--keywords', kw, '--limit', limit]);\n// after\nconst limit = Math.min(10, Math.max(1, parseInt(userSuppliedLimit, 10) || 5));\nawait runCli(['people-search', '--keywords', kw, '--limit', String(limit)]);","handlingStrategy":"validation","validationCode":"function validateLimit(value) {\n  if (value === undefined || value === null || value === '') return 5;\n  const n = Number(value);\n  if (!Number.isInteger(n) || n < 1 || n > 10) throw new Error('--limit must be an integer between 1 and 10');\n  return n;\n}","typeGuard":"function isValidLimit(v) {\n  return v === undefined || v === null || v === '' || (Number.isInteger(Number(v)) && Number(v) >= 1 && Number(v) <= 10);\n}","tryCatchPattern":"try {\n  await runCli(['linkedin', 'people-search', '--keywords', kw, '--limit', limitInput]);\n} catch (err) {\n  if (String(err.message).startsWith('--limit must be')) {\n    console.error('Valid range: 1-10 (default 5)');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Clamp user-supplied limits with Math.min(10, Math.max(1, n)) before invoking","Parse integers with parseInt/Number and reject floats and comma-formatted strings","Update legacy scripts that used limits above 10 after the MAX_LIMIT cap","Surface the valid range in your own CLI/wrapper help text"],"tags":["argument-validation","cli","range-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}