{"record":{"id":"013256ac3171a7a1","repo":"jackwener/OpenCLI","slug":"boss-wt2-t-cookies-missing","errorCode":null,"errorMessage":"Boss wt2 / t cookies missing","messagePattern":"Boss wt2 / t cookies missing","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/boss/auth.js","lineNumber":15,"sourceCode":"import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\n// Keep the helper within the adapter so `opencli adapter eject boss` remains runnable.\nimport { registerSiteAuthCommands } from '../_shared/site-auth.js';\n\nconst BOSS_GEEK_JOBS_URL = 'https://www.zhipin.com/web/geek/jobs';\n\nasync function hasBossSessionCookie(page) {\n  const cookies = await page.getCookies({ url: 'https://www.zhipin.com' });\n  const names = new Set(cookies.map(c => c.name));\n  return names.has('wt2') || names.has('t');\n}\n\nasync function verifyBossIdentity(page) {\n  if (!await hasBossSessionCookie(page)) {\n    throw new AuthRequiredError('zhipin.com', 'Boss wt2 / t cookies missing');\n  }\n  await page.goto(BOSS_GEEK_JOBS_URL);\n  await page.wait(3);\n  const probe = await page.evaluate(`\n    (() => {\n      const path = location.pathname || '';\n      if (/\\\\/web\\\\/user\\\\/login|\\\\/login\\\\.html/.test(location.href)) {\n        return { kind: 'auth', detail: 'Boss redirected to login page' };\n      }\n      const userType = /\\\\/web\\\\/geek\\\\//.test(path) ? 'geek' : /\\\\/web\\\\/(boss|recruit|chat\\\\/boss)/.test(path) ? 'recruiter' : '';\n      if (!userType) {\n        return { kind: 'auth', detail: 'Boss path does not look like authenticated geek/recruiter page: ' + path };\n      }\n      return { ok: true, user_type: userType };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('zhipin.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Boss probe: ${JSON.stringify(probe)}`);","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/auth.js#L1-L33","documentation":"verifyBossIdentity throws AuthRequiredError when the zhipin.com browser context contains neither the 'wt2' nor the 't' session cookie, meaning there is no authenticated BOSS直聘 session. The library requires one of these cookies before it will navigate and probe the authenticated area. It signals the user must log in via the interactive browser login flow.","triggerScenarios":"Calling the boss site auth verify/quick-check (or any boss command that runs identity verification) with a browser profile that has never logged in to zhipin.com, or after cookies were cleared/expired. Also raised by quickCheck hasBossSessionCookie before any navigation.","commonSituations":"Fresh browser profile with no saved login; zhipin.com session expired server-side and cookies were purged; using a headless profile isolated from the one where the user logged in; proxy/IP change causing the site to invalidate the session.","solutions":["Run the boss login command to open https://login.zhipin.com/ and complete the interactive login (including SMS/QR verification)","Verify the browser profile used by the CLI is the same profile where you previously logged in","Manually browse zhipin.com in the automation browser to confirm wt2/t cookies exist (document.cookie or DevTools)","Re-login if the site invalidated the session (check for 302 redirects to login.zhipin.com)"],"exampleFix":"// before: verify with expired profile\nawait verifyBossIdentity(page); // throws\n// after: login first\nawait runSiteLogin('boss'); // opens login.zhipin.com, waits for wt2/t cookie\nconst identity = await verifyBossIdentity(page);","handlingStrategy":"validation","validationCode":"// Check for boss session cookies before invoking any boss command\nconst cookies = await page.context().cookies('https://www.zhipin.com');\nconst names = new Set(cookies.map(c => c.name));\nif (!names.has('wt2') && !names.has('t')) {\n  await runInteractiveLogin('boss'); // open login.zhipin.com first\n}","typeGuard":"function hasBossSession(cookies) {\n  return Array.isArray(cookies) &&\n    cookies.some(c => c.name === 'wt2' || c.name === 't');\n}","tryCatchPattern":"try {\n  await bossVerify(page);\n} catch (err) {\n  if (err instanceof AuthRequiredError && err.message.includes('cookies missing')) {\n    await interactiveLogin('https://login.zhipin.com/');\n    return bossVerify(page);\n  }\n  throw err;\n}","preventionTips":["Use a persistent browser profile dedicated to the CLI so cookies survive restarts","Re-login proactively when zhipin.com sessions expire rather than letting commands fail","Avoid sharing profiles between headless and headed sessions","Check for wt2/t cookies in DevTools before running batch jobs"],"tags":["authentication","cookies","session","zhipin"],"backgroundTag":"missing-session-cookie","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}