{"record":{"id":"44ee0be84ee77f16","repo":"jackwener/OpenCLI","slug":"context-requires-an-active-signed-in-linkedin-b","errorCode":null,"errorMessage":"${context} requires an active signed-in LinkedIn browser session","messagePattern":"(.+?) requires an active signed-in LinkedIn browser session","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/search.js","lineNumber":162,"sourceCode":"    return /\\b(sign in|log in|join linkedin)\\b/.test(text) ||\n        /linkedin\\.com\\/(login|checkpoint|authwall)/i.test(text) ||\n        /\\b(captcha|verification required)\\b/.test(text) ||\n        /(请登录|登录领英|安全验证)/.test(text);\n}\nfunction buildLinkedInAuthProbeScript() {\n    return `(() => {\n      const text = [\n        window.location.href || '',\n        document.title || '',\n        document.body ? (document.body.innerText || '').slice(0, 4000) : '',\n      ].join('\\\\n');\n      return ${looksLinkedInAuthWallText.toString()}(text);\n    })()`;\n}\nasync function assertLinkedInAuthenticated(page, context) {\n    const authRequired = await page.evaluate(buildLinkedInAuthProbeScript());\n    if (authRequired) {\n        throw new AuthRequiredError(LINKEDIN_DOMAIN, `${context} requires an active signed-in LinkedIn browser session`);\n    }\n}\n// ── Company ID resolution (requires DOM interaction) ──────────────────\nasync function resolveCompanyIds(page, input) {\n    const rawValues = parseCsvArg(input);\n    const ids = new Set();\n    const names = [];\n    for (const value of rawValues) {\n        if (/^\\d+$/.test(value))\n            ids.add(value);\n        else\n            names.push(value);\n    }\n    if (!names.length)\n        return [...ids];\n    const resolved = await page.evaluate(`(async () => {\n    const targets = ${JSON.stringify(names)};\n    const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/search.js#L144-L180","documentation":"assertLinkedInAuthenticated runs a page-evaluated probe script that detects LinkedIn's auth wall (login redirects / wall text); if the probe reports authentication is required it throws AuthRequiredError(LINKEDIN_DOMAIN, `${context} requires an active signed-in LinkedIn browser session`). It converts LinkedIn's silent auth-wall into an explicit, typed error before the command wastes effort.","triggerScenarios":"Calling enrichJobDetails (or other probe-protected flows) while the browser session is logged out, the session cookie expired mid-run, LinkedIn served an auth wall/redirect on the job URL, or the page navigated to a login/challenge page.","commonSituations":"Long-running scripts whose LinkedIn session expired between commands; scraping after a password change or security challenge (2FA) invalidated cookies; running against a fresh browser profile that never logged in; LinkedIn rate-limiting into a wall that looks like an auth page.","solutions":["Re-run the CLI's LinkedIn login flow in the browser session to refresh cookies, then retry.","Verify manually in the browser that linkedin.com shows a signed-in feed.","Add a pre-check that calls the auth probe (or assertLinkedInAuthenticated) and triggers login before batch jobs.","Catch AuthRequiredError in batch loops to pause and re-authenticate rather than failing the whole run.","Reduce request pace; challenge walls can be triggered by aggressive scraping."],"exampleFix":"// before\nawait enrichJobDetails(page, url)   // session expired -> AuthRequiredError\n// after\ntry {\n  await enrichJobDetails(page, url)\n} catch (e) {\n  if (e.name === 'AuthRequiredError') {\n    await login(page)               // refresh LinkedIn session\n    await enrichJobDetails(page, url)\n  } else throw e\n}","handlingStrategy":"try-catch","validationCode":"const authRequired = await page.evaluate(buildLinkedInAuthProbeScript()); if (authRequired) await login(page);","typeGuard":"null","tryCatchPattern":"try { await enrichJobDetails(page, url) } catch (e) { if (e.name === 'AuthRequiredError' || /signed-in LinkedIn browser session/.test(e.message)) { await login(page); return enrichJobDetails(page, url); } throw e; }","preventionTips":["Run the auth probe before long batch jobs and re-login on failure.","Persist and refresh LinkedIn cookies; detect expiry proactively.","Slow request rates to avoid challenge walls.","Catch AuthRequiredError in loops to pause for re-auth instead of aborting.","Verify sign-in manually after password changes or security challenges."],"tags":["auth-required","session-expired","linkedin","authentication"],"backgroundTag":"auth-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}