{"record":{"id":"ccf32ac303bc513f","repo":"jackwener/OpenCLI","slug":"sales-navigator-messaging-threads-api-reached-the","errorCode":null,"errorMessage":"Sales Navigator messaging threads API reached the ${maxPages}-page safety cap before collecting ${limit} conversations","messagePattern":"Sales Navigator messaging threads API reached the (.+?)-page safety cap before collecting (.+?) conversations","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-inbox.js","lineNumber":160,"sourceCode":"    const pageRows = parseSalesnavThreads(json);\n    if (pageRows.length === 0) break;\n    for (const row of pageRows) {\n      if (seen.has(row.thread_id)) continue;\n      seen.add(row.thread_id);\n      rows.push(row);\n      if (rows.length >= limit) break;\n    }\n    const last = pageRows[pageRows.length - 1];\n    const next = last?.next_page_starts_at;\n    hasMorePages = Boolean(next);\n    if (!next) break;\n    if (next === pageStartsAt) {\n      throw new CommandExecutionError('Sales Navigator messaging threads API returned the same cursor twice');\n    }\n    pageStartsAt = next;\n  }\n  if (rows.length < limit && hasMorePages && pagesFetched >= maxPages) {\n    throw new CommandExecutionError(`Sales Navigator messaging threads API reached the ${maxPages}-page safety cap before collecting ${limit} conversations`);\n  }\n  return rows.slice(0, limit).map((row, index) => ({ ...row, rank: index + 1 }));\n}\n\nexport { THREAD_DECORATION, THREADS_BASE };\n\ncli({\n  site: 'linkedin',\n  name: 'salesnav-inbox',\n  access: 'read',\n  description: 'List LinkedIn Sales Navigator message conversations with API pagination',\n  domain: LINKEDIN_DOMAIN,\n  strategy: Strategy.UI,\n  browser: true,\n  args: [\n    { name: 'limit', type: 'number', default: DEFAULT_LIMIT, help: 'Maximum conversations to return (1-500)' },\n    { name: 'max-pages', type: 'number', default: 30, help: 'Maximum Sales Navigator API pages to fetch' },\n    { name: 'unread-only', type: 'bool', default: false, help: 'Return only unread conversations' },","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-inbox.js#L142-L178","documentation":"fetchInboxRows enforces a --max-pages safety cap (default 30). If it hits that cap while the API still reports more pages (hasMorePages) and fewer than --limit conversations were collected, it throws rather than returning partial or misleading results.","triggerScenarios":"rows.length < limit, hasMorePages is true, and pagesFetched >= maxPages — the inbox has more conversations than maxPages iterations of ~page-size rows can deliver.","commonSituations":"Large Sales Navigator inbox with hundreds of threads while default max-pages=30 is too small; user raised --limit (up to 500) without raising --max-pages; slow page sizes shrink rows-per-page so the cap is exhausted early.","solutions":["Increase --max-pages (e.g. --max-pages 100) to allow more cursor hops.","Lower --limit so it fits within the page budget.","Re-run the command; partial API responses (small rows per page) may resolve on retry.","Check the inbox is not flooded with archived threads that inflate page count."],"exampleFix":"// before\nlinkedin salesnav-inbox --limit 500\n// after\nlinkedin salesnav-inbox --limit 500 --max-pages 100","handlingStrategy":"validation","validationCode":"const limit = 500, maxPages = 30;\nif (limit > maxPages * 10) console.warn(`limit ${limit} likely exceeds ${maxPages} pages; raise --max-pages`);","typeGuard":null,"tryCatchPattern":"try { await fetchInboxRows(page, { limit, maxPages }); } catch (e) { if (/safety cap/.test(e.message)) { return fetchInboxRows(page, { limit, maxPages: maxPages * 2 }); } throw e; }","preventionTips":["Set --max-pages proportional to --limit (roughly limit / rows-per-page, with headroom).","Lower --limit if you don't need the whole inbox.","Remember the default max-pages is 30.","Watch for small page sizes in big inboxes; they exhaust the cap sooner."],"tags":["pagination","sales-navigator","limits"],"backgroundTag":"pagination-safety-cap-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}