{"record":{"id":"0fa2af8cae15a496","repo":"jackwener/OpenCLI","slug":"limit-must-be-an-integer-between-1-and-500","errorCode":null,"errorMessage":"--limit must be an integer between 1 and 500","messagePattern":"--limit must be an integer between 1 and 500","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-search.js","lineNumber":28,"sourceCode":"// /sales/search/people request.\nconst LEAD_SEARCH_DECORATION = 'com.linkedin.sales.deco.desktop.searchv2.LeadSearchResult-14';\nconst PAGE_SIZE = 25;\n\nfunction normalizeWhitespace(value) {\n  return String(value ?? '').replace(/[  ]/g, ' ').replace(/\\s+/g, ' ').trim();\n}\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 25;\n  const limit = Number(value);\n  if (!Number.isInteger(limit) || limit < 1 || limit > 500) {\n    throw new ArgumentError('--limit must be an integer between 1 and 500');\n  }\n  return limit;\n}\n\n// Sales Navigator keeps the structural ( ) , : of the query literal and only\n// percent-encodes the keyword value.\nfunction leadSearchUrl(keywords, start) {\n  const query = '(spellCorrectionEnabled:true,recentSearchParam:(doLogHistory:true),keywords:'\n    + encodeURIComponent(keywords) + ')';\n  return LEAD_SEARCH_BASE\n    + '?q=searchQuery&query=' + query\n    + '&start=' + start + '&count=' + PAGE_SIZE\n    + '&decorationId=' + LEAD_SEARCH_DECORATION;\n}\n\nfunction fetchLeadSearchScript(url, csrf) {\n  return String.raw`(async () => {\n    const headers = {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-search.js#L10-L46","documentation":"parseLimit validates the --limit argument: it must be an integer from 1 to 500 (default 25 when omitted). Non-numeric strings, floats, or out-of-range values throw ArgumentError.","triggerScenarios":"Passing --limit 0, --limit 501, --limit abc, --limit 25.5, or any value Number() cannot turn into an integer.","commonSituations":"Users assuming a larger page size is allowed (Sales Navigator caps at 500); copying a limit from another CLI with different bounds; locale-formatted numbers like '1,000'.","solutions":["Use an integer in [1, 500], e.g. --limit 100.","Omit --limit entirely to use the default of 25.","Clamp or validate the value in your wrapper script before invoking the CLI."],"exampleFix":"// before\n--limit 1000\n// after\n--limit 500","handlingStrategy":"validation","validationCode":"const n = Number(rawLimit);\nif (!Number.isInteger(n) || n < 1 || n > 500) throw new Error('--limit must be an integer between 1 and 500');","typeGuard":"function isValidLimit(v) {\n  const n = Number(v);\n  return Number.isInteger(n) && n >= 1 && n <= 500;\n}","tryCatchPattern":null,"preventionTips":["Clamp user-supplied limits to 1..500 before invoking","Omit the flag to accept the default of 25","Sanitize locale-formatted numbers (strip commas) first","Document the 500 cap in tooling that surfaces this CLI"],"tags":["argument-validation","cli","limit","range-check"],"backgroundTag":"invalid-range-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}