{"record":{"id":"57a685ff5e41863e","repo":"jackwener/OpenCLI","slug":"prefix-data-message-unknown-error-code","errorCode":null,"errorMessage":"${prefix}${data.message || 'Unknown error'} (code=${data.code})","messagePattern":"(.+?)(.+?) \\(code=(.+?)\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/boss/utils.js","lineNumber":96,"sourceCode":"        throw new AuthRequiredError(BOSS_DOMAIN, RECRUITER_ONLY_MSG);\n    }\n}\n/**\n * Throw if the API response is not code 0.\n * Checks for cookie expiry first, then identity mismatch, then throws\n * with the provided message.\n */\nexport function assertOk(data, errorPrefix) {\n    if (!data || typeof data !== 'object') {\n        throw new CommandExecutionError(`${errorPrefix ? `${errorPrefix}: ` : ''}Boss API returned malformed response`);\n    }\n    if (data.code === 0)\n        return;\n    checkEnvironment(data);\n    checkAuth(data);\n    checkRecruiterSide(data);\n    const prefix = errorPrefix ? `${errorPrefix}: ` : '';\n    throw new CommandExecutionError(`${prefix}${data.message || 'Unknown error'} (code=${data.code})`);\n}\n/**\n * Make a credentialed XHR request via page.evaluate().\n *\n * This is the single XHR template — no more copy-pasting the same 15-line\n * XMLHttpRequest boilerplate across every adapter.\n *\n * @returns Parsed JSON response\n * @throws On network error, timeout, JSON parse failure, or cookie expiry\n */\nexport async function bossFetch(page, url, opts = {}) {\n    const method = opts.method ?? 'GET';\n    const timeout = opts.timeout ?? DEFAULT_TIMEOUT;\n    const body = opts.body ?? null;\n    // Build the evaluate script. We use JSON.stringify for safe interpolation.\n    const script = `\n    async () => {\n      return new Promise((resolve, reject) => {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/utils.js#L78-L114","documentation":"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.).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the Chinese message and code in the error — they come from BOSS and identify the exact business failure.","Retry after a delay if the code indicates rate limiting or a transient BOSS error.","Validate the uids/jobIds you pass (they may have expired or been deleted).","Confirm the account has the permission that endpoint requires (recruiter vs seeker, verified employer).","Set OPENCLI_VERBOSE and inspect which wapi URL returned the code to pinpoint the failing call."],"exampleFix":"// before\nawait bossFetch(page, urlWithStaleJobId);\n// CommandExecutionError: ... (code=1101)\n// after\nconst job = await fetchJobList(page);\nawait bossFetch(page, urlWith(job.id)); // use fresh jobId from the API","handlingStrategy":"try-catch","validationCode":"const probe = await bossFetch(page, url, { allowNonZero: true });\nif (probe.code !== 0) console.error(`BOSS pre-check failed: ${probe.message} (code=${probe.code})`);","typeGuard":"function isOk(v) {\n  return typeof v === 'object' && v !== null && v.code === 0;\n}","tryCatchPattern":"try {\n  await runBossCommand();\n} catch (e) {\n  const m = e.message.match(/\\(code=(\\d+)\\)/);\n  if (e instanceof CommandExecutionError && m) {\n    console.error(`BOSS business error ${m[1]}: ${e.message}. Validate ids/permissions, then retry.`);\n    return;\n  }\n  throw e;\n}","preventionTips":["Read the embedded BOSS message and code before retrying","Refresh stale uids/jobIds from a fresh list call before using them","Respect rate limits; add delays between calls","Verify account permissions for the endpoint (recruiter vs seeker)"],"tags":["api-error","business-error","boss-api"],"backgroundTag":"api-nonzero-code","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}