{"record":{"id":"e16ee6289662cde0","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-linkedin-salesnav-sea","errorCode":null,"errorMessage":"Browser session required for linkedin salesnav-search","messagePattern":"Browser session required for linkedin salesnav-search","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-search.js","lineNumber":137,"sourceCode":"  }\n  return result.json;\n}\n\ncli({\n  site: 'linkedin',\n  name: 'salesnav-search',\n  access: 'read',\n  description: 'Search LinkedIn Sales Navigator for people leads by keyword',\n  domain: LINKEDIN_DOMAIN,\n  strategy: Strategy.UI,\n  browser: true,\n  args: [\n    { name: 'keywords', type: 'string', required: true, positional: true, help: 'People search keywords, e.g. \"quality manager food manufacturing\"' },\n    { name: 'limit', type: 'number', default: 25, help: 'Maximum leads to return (1-500, fetched 25 per request)' },\n  ],\n  columns: ['rank', 'name', 'title', 'company', 'location', 'degree', 'profile_url', 'lead_url', 'recipient_urn'],\n  func: async (page, args) => {\n    if (!page) throw new CommandExecutionError('Browser session required for linkedin salesnav-search');\n    const keywords = requireStringArg(args, 'keywords', '--keywords');\n    const limit = parseLimit(args.limit);\n\n    await page.goto(SALES_HOME);\n    await page.wait(6);\n\n    const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\n    const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;\n    if (!jsession) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.');\n    }\n    const csrf = jsession.replace(/^\\\"|\\\"$/g, '');\n\n    const leads = [];\n    const seen = new Set();\n    for (let start = 0; leads.length < limit && start < 2000; start += PAGE_SIZE) {\n      const result = unwrapEvaluateResult(await page.evaluate(fetchLeadSearchScript(leadSearchUrl(keywords, start), csrf)));\n      const json = requireLeadSearchResult(result);","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-search.js#L119-L155","documentation":"Thrown at the top of the salesnav-search command function (clis/linkedin/salesnav-search.js:137) when the command is invoked without a live browser page. The command is registered with browser:true, so the registry is expected to inject an authenticated page; a falsy page means the automation runtime could not or did not provide one. The library deliberately fails fast instead of attempting API calls that require a real session.","triggerScenarios":"Calling the salesnav-search func directly (or via __test__ exports) with page=null/undefined; running through a runner that ignores the command's browser:true flag; the browser daemon failing to launch so the registry passes a null page to func.","commonSituations":"Invoking commands programmatically in scripts or tests without spinning up the browser session; headless CI environments where Chromium/playwright cannot start; misconfigured opencli runner that skips Strategy.UI session creation.","solutions":["Run the command through the opencli CLI runner so it creates the browser session required by Strategy.UI/browser:true instead of calling func directly.","Ensure the browser backend is installed and can launch (check playwright/chromium availability and DISPLAY settings in headless CI).","If calling programmatically, establish a session first and pass a valid, logged-in LinkedIn page as the first argument.","Check the registry/daemon logs to confirm the command was resolved with its browser:true metadata intact (a custom registry wrapper may drop it)."],"exampleFix":"// before (direct call, no page)\nawait salesNavSearchFunc(null, { keywords: 'quality manager' });\n// after (open a session first)\nconst page = await openBrowserSession({ site: 'linkedin', domain: 'www.linkedin.com' });\nawait salesNavSearchFunc(page, { keywords: 'quality manager' });","handlingStrategy":"validation","validationCode":"// Check runtime prerequisites before invoking the command:\nif (!page || typeof page.evaluate !== 'function') {\n  throw new Error('salesnav-search requires a live browser page; run via the opencli runner with browser support');\n}","typeGuard":"function hasBrowserPage(p) {\n  return Boolean(p) && typeof p.goto === 'function' && typeof p.evaluate === 'function';\n}","tryCatchPattern":"try {\n  await run('linkedin salesnav-search', [keywords]);\n} catch (err) {\n  if (/Browser session required/.test(err.message)) {\n    console.error('Launch the opencli browser session first (check chromium install / headless setup).');\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Always invoke browser:true commands through the opencli runner instead of calling func directly.","Verify Chromium/playwright is installed and launchable in CI before starting pipeline runs.","In headless environments, confirm DISPLAY/xvfb configuration so the UI strategy can create the page."],"tags":["linkedin","browser-session","missing-page","setup"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}