jackwener/OpenCLI · error · CommandExecutionError

(code= )

Error message

${prefix}${data.message || 'Unknown error'} (code=${data.code})

What it means

After assertOk's specialized checks (environment, cookie, identity) all pass, any remaining non-zero BOSS code is thrown as CommandExecutionError '<prefix><message> (code=<code>)'. This is the generic BOSS API business-error path — the message text and numeric code come straight from BOSS and indicate whatever that endpoint rejected (permission, rate limit, invalid parameters, empty results, etc.).

Solutions

  1. Read the Chinese message and code in the error — they come from BOSS and identify the exact business failure.
  2. Retry after a delay if the code indicates rate limiting or a transient BOSS error.
  3. Validate the uids/jobIds you pass (they may have expired or been deleted).
  4. Confirm the account has the permission that endpoint requires (recruiter vs seeker, verified employer).
  5. Set OPENCLI_VERBOSE and inspect which wapi URL returned the code to pinpoint the failing call.

Example fix

// before
await bossFetch(page, urlWithStaleJobId);
// CommandExecutionError: ... (code=1101)
// after
const job = await fetchJobList(page);
await bossFetch(page, urlWith(job.id)); // use fresh jobId from the API
Defensive patterns

Strategy: try-catch

Validate before calling

const probe = await bossFetch(page, url, { allowNonZero: true });
if (probe.code !== 0) console.error(`BOSS pre-check failed: ${probe.message} (code=${probe.code})`);

Type guard

function isOk(v) {
  return typeof v === 'object' && v !== null && v.code === 0;
}

Try / catch

try {
  await runBossCommand();
} catch (e) {
  const m = e.message.match(/\(code=(\d+)\)/);
  if (e instanceof CommandExecutionError && m) {
    console.error(`BOSS business error ${m[1]}: ${e.message}. Validate ids/permissions, then retry.`);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Any bossFetch (or direct assertOk from captureJobList) receiving a non-zero code that is not 7/37/24 and not code-37-with-environment-marker — e.g. code for rate limiting, invalid jobId, or insufficient permission on that endpoint.

Common situations: Passing a stale jobId/uid that no longer exists; hitting per-account rate limits; calling an endpoint your account lacks permission for; BOSS-side transient errors during maintenance.

Related errors


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

Appendix: source

Thrown at clis/boss/utils.js:96

        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})`);
}
/**
 * Make a credentialed XHR request via page.evaluate().
 *
 * This is the single XHR template — no more copy-pasting the same 15-line
 * XMLHttpRequest boilerplate across every adapter.
 *
 * @returns Parsed JSON response
 * @throws On network error, timeout, JSON parse failure, or cookie expiry
 */
export async function bossFetch(page, url, opts = {}) {
    const method = opts.method ?? 'GET';
    const timeout = opts.timeout ?? DEFAULT_TIMEOUT;
    const body = opts.body ?? null;
    // Build the evaluate script. We use JSON.stringify for safe interpolation.
    const script = `
    async () => {
      return new Promise((resolve, reject) => {

View on GitHub (pinned to 49907e53dc)