{"record":{"id":"70db717d3b0244cc","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-linkedin-sent-invitat","errorCode":null,"errorMessage":"Browser session required for linkedin sent-invitations","messagePattern":"Browser session required for linkedin sent-invitations","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/sent-invitations.js","lineNumber":91,"sourceCode":"      malformedCount,\n      count: rows.length,\n      rows,\n    };\n  })()`;\n}\n\ncli({\n  site: 'linkedin',\n  name: 'sent-invitations',\n  access: 'read',\n  description: 'List pending LinkedIn sent invitations for CRM reconciliation',\n  domain: LINKEDIN_DOMAIN,\n  strategy: Strategy.UI,\n  browser: true,\n  args: [],\n  columns: ['rank', 'name', 'profile_url', 'invited_date_text'],\n  func: async (page) => {\n    if (!page) throw new CommandExecutionError('Browser session required for linkedin sent-invitations');\n    await page.goto(SENT_URL);\n    await page.wait(12);\n    let result = unwrapEvaluateResult(await page.evaluate(buildSentInvitationsScript()));\n    if (result?.authRequired) {\n      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn sent invitations requires an active signed-in browser session.');\n    }\n    if (result?.warning) {\n      throw new CommandExecutionError('LinkedIn warning/restriction state visible on sent invitations page.');\n    }\n    if (!result || typeof result !== 'object' || Array.isArray(result) || !Array.isArray(result.rows)) {\n      throw new CommandExecutionError('LinkedIn sent invitations returned a malformed extraction payload.');\n    }\n    if (result.malformedCount > 0) {\n      throw new CommandExecutionError('LinkedIn sent invitations contained a malformed invitation card.');\n    }\n    const rows = result.rows;\n    if (rows.length === 0) {\n      if (result.explicitEmpty) {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/sent-invitations.js#L73-L109","documentation":"The sent-invitations command is registered with browser: true and Strategy.UI, meaning it needs a live browser page. If the CLI runtime invokes the command's func without a page object (no browser could be launched or the session was not created), the func immediately throws this CommandExecutionError rather than dereferencing null.","triggerScenarios":"Invoking `opencli linkedin sent-invitations` in an environment where the browser-backed session could not be established (browser launch failure, headless environment without a browser binary, session pool returning null page), so func receives page === null/undefined.","commonSituations":"Running on a server/CI without Chrome/Chromium installed; browser launch crashing due to missing sandbox dependencies; misconfigured CLI runtime that skips browser provisioning for UI-strategy commands; running the command outside the CLI harness with page omitted.","solutions":["Ensure a Chromium/Chrome browser is installed and launchable in the environment, then re-run the command.","Check CLI/browser provisioning logs for the underlying launch failure (missing display, missing --no-sandbox, crashed binary) and fix that root cause.","Run in an environment with a display or proper headless flags (e.g. xvfb, --headless=new, --no-sandbox).","If calling the func programmatically, always pass a live page from the CLI session instead of undefined."],"exampleFix":"// before (no display in CI -> page is null)\n// CI: npx opencli linkedin sent-invitations\n// after — provide a virtual display / headless browser\n// CI install: apt-get install -y chromium xvfb\n// CI run: xvfb-run npx opencli linkedin sent-invitations","handlingStrategy":"fallback","validationCode":"// Verify a browser is available before invoking UI-strategy commands\nimport { executablePath } from '...'; // or check chromium on PATH\nimport { existsSync } from 'fs';\nif (!existsSync(chromiumPath)) {\n  console.error('Chromium not found; install it or set the browser path before running linkedin sent-invitations.');\n  process.exit(1);\n}","typeGuard":"const hasLivePage = (page) => Boolean(page) && typeof page.goto === 'function' && typeof page.evaluate === 'function';","tryCatchPattern":"let rows;\ntry {\n  rows = await run(['linkedin', 'sent-invitations']);\n} catch (e) {\n  if (/Browser session required/.test(e.message)) {\n    console.error('Browser could not be provisioned. Install Chromium / configure headless flags, then retry.');\n    process.exit(3);\n  }\n  throw e;\n}","preventionTips":["Install Chrome/Chromium in every environment (CI images, containers) that runs LinkedIn commands.","Provide a virtual display (xvfb) or correct headless flags on display-less hosts.","Check browser-launch logs for missing sandbox dependencies (--no-sandbox, libnss3) in containers.","Smoke-test browser provisioning at pipeline start, not mid-run."],"tags":["linkedin","browser-session","environment","browser-launch"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}