{"record":{"id":"7fa52ae5a205c39b","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-linkedin-job-detail","errorCode":null,"errorMessage":"Browser session required for linkedin job-detail","messagePattern":"Browser session required for linkedin job-detail","errorType":"error_code","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/job-detail.js","lineNumber":153,"sourceCode":"    url: normalizeHttpUrl(row.url),\n    description: normalizeWhitespace(row.description),\n  };\n}\n\ncli({\n  site: 'linkedin',\n  name: 'job-detail',\n  access: 'read',\n  description: 'Read one LinkedIn job page with description, apply URL, workplace type, applicants, and company metadata',\n  domain: 'www.linkedin.com',\n  strategy: Strategy.COOKIE,\n  browser: true,\n  args: [\n    { name: 'job-url', type: 'string', required: true, positional: true, help: 'Exact LinkedIn job URL, e.g. https://www.linkedin.com/jobs/view/123/' },\n  ],\n  columns: ['title', 'company', 'location', 'workplace_type', 'job_type', 'applicants', 'listed', 'apply_url', 'company_url', 'url', 'description'],\n  func: async (page, args) => {\n    if (!page) throw new CommandExecutionError('Browser session required for linkedin job-detail');\n    const jobUrl = normalizeJobUrl(args['job-url']);\n    await page.goto(jobUrl);\n    await page.wait(4);\n    await assertLinkedInAuthenticated(page, 'LinkedIn job-detail');\n    const row = unwrapEvaluateResult(await page.evaluate(buildExtractionScript()));\n    return [normalizeDetail(row)];\n  },\n});\n\nexport const __test__ = {\n  normalizeJobUrl,\n  decodeLinkedinRedirect,\n  normalizeDetail,\n};\n","sourceCodeStart":135,"sourceCodeEnd":168,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/job-detail.js#L135-L168","documentation":"CommandExecutionError thrown when the linkedin job-detail command's func is invoked without a browser page object. This command is declared with browser:true so it only works inside a logged-in browser session; the throw is a fail-fast guard at clis/linkedin/job-detail.js:153 before any navigation happens. It indicates the CLI harness did not supply a page, meaning the command was run outside a browser-enabled context or the session failed to initialize.","triggerScenarios":"Calling the job-detail command's func with page === null/undefined — e.g. running the CLI without an active browser session, a failed COOKIE-strategy login leaving no page, or invoking func programmatically without a page argument.","commonSituations":"Expired or missing LinkedIn cookies so the browser session never starts; running the command in a headless environment where browser launch failed; calling the exported func directly in tests without a mocked page; CI containers lacking Chromium.","solutions":["Launch the command through the normal CLI path so the browser:true flag spins up a page before func runs","Ensure LinkedIn cookies for www.linkedin.com are configured and valid so the session starts","Check browser launch logs/dependencies (Chromium installed, not blocked in sandbox) if the session silently fails","When calling func directly in tests, pass a stub page object satisfying goto/wait/evaluate"],"exampleFix":"// before\nawait commands['linkedin/job-detail'].func(null, { 'job-url': 'https://www.linkedin.com/jobs/view/123/' });\n// after\nconst page = await startBrowserSession({ cookies: linkedinCookies });\nawait commands['linkedin/job-detail'].func(page, { 'job-url': 'https://www.linkedin.com/jobs/view/123/' });","handlingStrategy":"try-catch","validationCode":"if (typeof page === 'undefined' || !page) {\n  throw new Error('Start a browser session (valid LinkedIn cookies required) before running linkedin job-detail');\n}\nif (!/^https:\\/\\/www\\.linkedin\\.com\\/jobs\\/view\\/\\d+\\/?/.test(jobUrl)) {\n  throw new Error('job-url must be a LinkedIn job view URL');\n}","typeGuard":"function hasBrowserPage(page) {\n  return typeof page === 'object' && page !== null && typeof page.goto === 'function' && typeof page.evaluate === 'function';\n}","tryCatchPattern":"try {\n  const rows = await runCli(['linkedin', 'job-detail', jobUrl]);\n} catch (err) {\n  if (String(err.message).includes('Browser session required')) {\n    await startBrowserSession({ cookies: loadLinkedInCookies() });\n    // retry once\n  } else throw err;\n}","preventionTips":["Always launch the command through the CLI entry so browser:true starts a session","Keep LinkedIn cookies fresh; re-login before long-running jobs","Install/verify Chromium availability in CI before running browser commands","When calling func directly, always pass a page stub with goto/wait/evaluate"],"tags":["browser-session","linkedin","session-required"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}