jackwener/OpenCLI · error · AuthRequiredError

BOSS redirected the job detail page to the login flow

Error message

BOSS redirected the job detail page to the login flow

What it means

captureJobDetail throws AuthRequiredError(BOSS_DOMAIN, 'BOSS redirected the job detail page to the login flow') when, after exhausting all read retries, the page is detected as a login wall (URL contains /login or passport, or a login form element is present). The library deliberately surfaces this as an auth signal — the pre-UI API path classified it the same way via assertOk — so callers don't mistake a logged-out session for a broken job page.

Source

Thrown at clis/boss/detail.js:136

async function captureJobDetail(page, jobId) {
    const url = `https://www.zhipin.com/job_detail/${encodeURIComponent(jobId)}.html`;
    await navigateTo(page, 'https://www.zhipin.com/web/geek/jobs', 2);
    for (let navigationAttempt = 0; navigationAttempt < 2; navigationAttempt++) {
        await navigateTo(page, url, 5);
        for (let attempt = 0; attempt < 5; attempt++) {
            try {
                const domRow = await readRenderedPage(page, jobId);
                if (domRow?.name && domRow?.description && domRow?.company) return domRow;
            } catch { /* wait for a complete render */ }
            if (attempt < 4) await page.wait(1);
        }
    }
    // The retry loop above swallows every read error, so without this check a
    // session that got bounced to the login wall reports "incomplete posting".
    // The API path this command replaced classified that as AuthRequiredError
    // via assertOk; keep that signal rather than losing it to the UI rewrite.
    if (await isLoginWall(page)) {
        throw new AuthRequiredError(BOSS_DOMAIN, 'BOSS redirected the job detail page to the login flow');
    }
    throw new CommandExecutionError('BOSS detail page did not expose a complete job posting');
}

async function isLoginWall(page) {
    try {
        return await page.evaluate(`
            (() => {
                const href = window.location.href || '';
                if (/\\/login|\\/user\\/login|passport/.test(href)) return true;
                return !!document.querySelector('.sign-form, .login-card, [class*="login-register"]');
            })()
        `) === true;
    } catch {
        return false;
    }
}
cli({

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate: run the BOSS login flow / `opencli boss login` (or open the browser session) and refresh cookies, then retry the command.
  2. Retry after completing any CAPTCHA/slider verification in the persistent browser session.
  3. Slow down request rate — aggressive sequential detail fetches can trigger risk-control login walls.
  4. Verify the session is alive with a cheap authenticated command before batch-fetching job details.
  5. Check cookies for www.zhipin.com are present and not expired in the profile used by the persistent session.

Example fix

// before
try { await detail(securityId) } catch (e) { console.error(e.message) }
// after
try {
  await detail(securityId);
} catch (e) {
  if (isAuthRequiredError(e)) { await bossLogin(); return detail(securityId); }
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// cheap authenticated call to verify the session before detail fetches
const list = await search({ query: 'test', limit: 1 }); // throws auth errors early if logged out

Type guard

function isAuthRequiredError(e) { return e && (e.name === 'AuthRequiredError' || /login flow/i.test(e.message || '')); }

Try / catch

try {
  const row = await detail(securityId);
} catch (e) {
  if (isAuthRequiredError(e)) {
    await reloginBoss(); // run the interactive login / refresh cookies
    return detail(securityId);
  }
  throw e;
}

Prevention

When it happens

Trigger: Session cookies expired or were invalidated so navigating to /job_detail/<id>.html redirects to the login flow; BOSS anti-bot measures force a re-login; running without ever completing `opencli` login for www.zhipin.com.

Common situations: Expired persistent session after days of inactivity; running headless from a server where the login session lapsed; BOSS risk-control bouncing frequent automated detail fetches to login; cookie strategy not yet established for the domain.

Related errors


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