jackwener/OpenCLI · error · AuthRequiredError

该命令仅支持招聘端(BOSS 端)账号,请使用招聘者账号登录后重试。

Error message

该命令仅支持招聘端(BOSS 端)账号,请使用招聘者账号登录后重试。

What it means

checkRecruiterSide maps BOSS API code 24 ('请切换身份后再试') to AuthRequiredError with a recruiter-only message. Several endpoints (recommend, joblist, stats, resume, mark, exchange, invite, greet, batchgreet) exist only for the recruiter (BOSS) side; calling them while logged in as a job-seeker (geek) returns code 24. Geek-side commands (chatlist/chatmsg) intentionally bypass this via allowNonZero and branch to the geek fetch instead.

Source

Thrown at clis/boss/utils.js:78

}
function checkEnvironment(data) {
    const message = String(data.message || '').toLowerCase();
    if (data.code === AMBIGUOUS_AUTH_CODE &&
        ENVIRONMENT_REJECTED_MARKERS.some((marker) => message.includes(marker.toLowerCase()))) {
        throw new CommandExecutionError(`Boss rejected the current browser environment: ${data.message || 'Unknown error'} (code=${data.code})`, '重新登录通常无法解决此问题。请保留当前页面,稍后重试,并在问题持续时上报完整错误信息。');
    }
}
/**
 * Map BOSS code=24 ("请切换身份后再试") to a typed AuthRequiredError.
 * Recruiter-only commands (recommend, joblist, stats, resume, mark,
 * exchange, invite, greet, batchgreet) have no geek-side equivalent;
 * surfacing this as a generic COMMAND_EXEC hides what the user must do.
 * chatlist / chatmsg avoid this path by using `allowNonZero: true` and
 * branching to the geek-side fetch when they see code 24.
 */
function checkRecruiterSide(data) {
    if (data.code === IDENTITY_MISMATCH_CODE) {
        throw new AuthRequiredError(BOSS_DOMAIN, RECRUITER_ONLY_MSG);
    }
}
/**
 * Throw if the API response is not code 0.
 * Checks for cookie expiry first, then identity mismatch, then throws
 * with the provided message.
 */
export function assertOk(data, errorPrefix) {
    if (!data || typeof data !== 'object') {
        throw new CommandExecutionError(`${errorPrefix ? `${errorPrefix}: ` : ''}Boss API returned malformed response`);
    }
    if (data.code === 0)
        return;
    checkEnvironment(data);
    checkAuth(data);
    checkRecruiterSide(data);
    const prefix = errorPrefix ? `${errorPrefix}: ` : '';
    throw new CommandExecutionError(`${prefix}${data.message || 'Unknown error'} (code=${data.code})`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log out of the geek account and log in with a recruiter (BOSS 端) account in the automation Chrome, then rerun.
  2. Verify which account type the current session is (the '切换身份' toggle on zhipin.com) before running recruiter-only commands.
  3. If you intended geek-side chat data, use the geek commands (chatlist/chatmsg) which handle code 24 by switching to the geek-side API instead.

Example fix

// before
cli greet --uid abc123   # logged in as geek -> code 24
// after
# switch the driven Chrome session to the recruiter account, then:
cli greet --uid abc123
Defensive patterns

Strategy: try-catch

Validate before calling

const probe = await bossFetch(page, recruiterOnlyProbeUrl, { allowNonZero: true });
if (probe.code === 24) {
  console.error('Current session is a job-seeker (geek) account; recruiter commands need a BOSS-side login.');
  process.exit(1);
}

Type guard

function isIdentityMismatch(data) {
  return !!data && typeof data === 'object' && data.code === 24;
}

Try / catch

try {
  await cli.joblist();
} catch (e) {
  if (e instanceof AuthRequiredError && /仅支持招聘端/.test(e.message)) {
    console.error('Switch the automation Chrome to a recruiter (BOSS-side) account and retry.');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running a recruiter-only command (e.g. `joblist`, `recommend`, `greet`) while the attached Chrome is logged into BOSS as a job-seeker (geek) account; the wapi endpoint replies code 24 identity mismatch.

Common situations: Sharing one Chrome profile between geek-side and boss-side commands; switching account type on zhipin.com and forgetting which identity is active; a company account that is primarily a seeker account.

Related errors


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