jackwener/OpenCLI · error · AuthRequiredError

Boss wt2 / t cookies missing

Error message

Boss wt2 / t cookies missing

What it means

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.

Source

Thrown at clis/boss/auth.js:15

import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
// Keep the helper within the adapter so `opencli adapter eject boss` remains runnable.
import { registerSiteAuthCommands } from '../_shared/site-auth.js';

const BOSS_GEEK_JOBS_URL = 'https://www.zhipin.com/web/geek/jobs';

async function hasBossSessionCookie(page) {
  const cookies = await page.getCookies({ url: 'https://www.zhipin.com' });
  const names = new Set(cookies.map(c => c.name));
  return names.has('wt2') || names.has('t');
}

async function verifyBossIdentity(page) {
  if (!await hasBossSessionCookie(page)) {
    throw new AuthRequiredError('zhipin.com', 'Boss wt2 / t cookies missing');
  }
  await page.goto(BOSS_GEEK_JOBS_URL);
  await page.wait(3);
  const probe = await page.evaluate(`
    (() => {
      const path = location.pathname || '';
      if (/\\/web\\/user\\/login|\\/login\\.html/.test(location.href)) {
        return { kind: 'auth', detail: 'Boss redirected to login page' };
      }
      const userType = /\\/web\\/geek\\//.test(path) ? 'geek' : /\\/web\\/(boss|recruit|chat\\/boss)/.test(path) ? 'recruiter' : '';
      if (!userType) {
        return { kind: 'auth', detail: 'Boss path does not look like authenticated geek/recruiter page: ' + path };
      }
      return { ok: true, user_type: userType };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('zhipin.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Boss probe: ${JSON.stringify(probe)}`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run the boss login command to open https://login.zhipin.com/ and complete the interactive login (including SMS/QR verification)
  2. Verify the browser profile used by the CLI is the same profile where you previously logged in
  3. Manually browse zhipin.com in the automation browser to confirm wt2/t cookies exist (document.cookie or DevTools)
  4. Re-login if the site invalidated the session (check for 302 redirects to login.zhipin.com)

Example fix

// before: verify with expired profile
await verifyBossIdentity(page); // throws
// after: login first
await runSiteLogin('boss'); // opens login.zhipin.com, waits for wt2/t cookie
const identity = await verifyBossIdentity(page);
Defensive patterns

Strategy: validation

Validate before calling

// Check for boss session cookies before invoking any boss command
const cookies = await page.context().cookies('https://www.zhipin.com');
const names = new Set(cookies.map(c => c.name));
if (!names.has('wt2') && !names.has('t')) {
  await runInteractiveLogin('boss'); // open login.zhipin.com first
}

Type guard

function hasBossSession(cookies) {
  return Array.isArray(cookies) &&
    cookies.some(c => c.name === 'wt2' || c.name === 't');
}

Try / catch

try {
  await bossVerify(page);
} catch (err) {
  if (err instanceof AuthRequiredError && err.message.includes('cookies missing')) {
    await interactiveLogin('https://login.zhipin.com/');
    return bossVerify(page);
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/013256ac3171a7a1. Report an issue: GitHub.