{"record":{"id":"28fafbbed9f8f70f","repo":"jackwener/OpenCLI","slug":"api-error","errorCode":"API_ERROR","errorMessage":"51job hot failed: ${data.message ?? 'unknown'}","messagePattern":"51job hot failed: (.+?)","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/51job/hot.js","lineNumber":50,"sourceCode":"    func: async (page, kwargs) => {\n        requirePage(page);\n        const limit = Math.max(1, Math.min(Number(kwargs.limit) || 20, 50));\n        const pageNum = Math.max(1, Number(kwargs.page) || 1);\n        const jobArea = resolveCity(kwargs.area);\n        const sortType = resolveCode(kwargs.sort, SORT_CODES, '0');\n\n        const currentUrl = await page.evaluate(`(() => window.location.href)()`);\n        if (!String(currentUrl).startsWith(WE_ORIGIN)) {\n            await navigateTo(page, `${WE_ORIGIN}/pc/search?searchType=2`, 2);\n        }\n\n        const url = buildSearchUrl({\n            keyword: '', jobArea, sortType,\n            pageNum, pageSize: Math.min(limit, 50),\n        });\n        const data = await pageFetchJson(page, url);\n        if (data.status !== '1' && data.status !== 1) {\n            throw new CliError('API_ERROR', `51job hot failed: ${data.message ?? 'unknown'}`);\n        }\n        const items = data?.resultbody?.job?.items ?? [];\n        if (items.length === 0) throw new CliError('NO_DATA', 'No recommended jobs returned');\n        return items.slice(0, limit).map((it, i) => mapJobItem(it, (pageNum - 1) * limit + i + 1));\n    },\n});\n","sourceCodeStart":32,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/51job/hot.js#L32-L57","documentation":"The hot-jobs command fetches 51job's search JSON API via pageFetchJson and checks data.status; when the API responds with a status other than '1'/1, the library throws CliError('API_ERROR') including the API-provided message (or 'unknown'). This is a server-side rejection of the query, not a client parsing failure.","triggerScenarios":"Calling the hot subcommand when 51job's search API returns an error status — invalid jobArea code, request throttled/blocked, API endpoint changed, or transient outage — thrown at clis/51job/hot.js:50.","commonSituations":"Passing an unsupported area/sortType code; heavy scraping triggering rate limiting; 51job API version change altering the response envelope; requesting during maintenance windows.","solutions":["Read the embedded data.message in the error to identify the API's specific complaint","Verify area and sortType values are valid codes the library recognizes","Back off and retry with delays — the status may indicate rate limiting","Update the library if 51job changed its API response format; check status handling still matches"],"exampleFix":"// before\nconst jobs = await cli.hot({ jobArea: 'XX' });\n// after\ntry {\n  const jobs = await cli.hot({ jobArea: '000000' }); // valid area code\n} catch (e) {\n  if (e.code === 'API_ERROR') console.error(e.message); // includes API message\n  await sleep(3000);\n  return cli.hot({ jobArea: '000000' });\n}","handlingStrategy":"retry","validationCode":"const VALID_AREAS = new Set(['000000','020000',...]); // only pass recognized area codes\nif (jobArea && !VALID_AREAS.has(jobArea)) throw new Error('unknown jobArea code');","typeGuard":"const isApiOk = (d) => d != null && (d.status === '1' || d.status === 1);","tryCatchPattern":"try {\n  return await cli.hot({ jobArea, sortType, page });\n} catch (e) {\n  if (e.code === 'API_ERROR') {\n    console.error('51job API:', e.message); // includes upstream message\n    await sleep(3000 * attempt);\n    return cli.hot({ jobArea, sortType, page });\n  }\n  throw e;\n}","preventionTips":["Use the library's documented code values for area/sortType","Throttle requests to avoid rate limiting","Log the embedded upstream message for diagnosis","Pin and update the library when 51job changes its API"],"tags":["api","http-error","rate-limit"],"backgroundTag":"upstream-api-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}