jackwener/OpenCLI · error · CliError
API_ERROR
API_ERROR
Error message
51job hot failed: ${data.message ?? 'unknown'} What it means
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.
Source
Thrown at clis/51job/hot.js:50
func: async (page, kwargs) => {
requirePage(page);
const limit = Math.max(1, Math.min(Number(kwargs.limit) || 20, 50));
const pageNum = Math.max(1, Number(kwargs.page) || 1);
const jobArea = resolveCity(kwargs.area);
const sortType = resolveCode(kwargs.sort, SORT_CODES, '0');
const currentUrl = await page.evaluate(`(() => window.location.href)()`);
if (!String(currentUrl).startsWith(WE_ORIGIN)) {
await navigateTo(page, `${WE_ORIGIN}/pc/search?searchType=2`, 2);
}
const url = buildSearchUrl({
keyword: '', jobArea, sortType,
pageNum, pageSize: Math.min(limit, 50),
});
const data = await pageFetchJson(page, url);
if (data.status !== '1' && data.status !== 1) {
throw new CliError('API_ERROR', `51job hot failed: ${data.message ?? 'unknown'}`);
}
const items = data?.resultbody?.job?.items ?? [];
if (items.length === 0) throw new CliError('NO_DATA', 'No recommended jobs returned');
return items.slice(0, limit).map((it, i) => mapJobItem(it, (pageNum - 1) * limit + i + 1));
},
});
View on GitHub (pinned to 49907e53dc)
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
Example fix
// before
const jobs = await cli.hot({ jobArea: 'XX' });
// after
try {
const jobs = await cli.hot({ jobArea: '000000' }); // valid area code
} catch (e) {
if (e.code === 'API_ERROR') console.error(e.message); // includes API message
await sleep(3000);
return cli.hot({ jobArea: '000000' });
} Defensive patterns
Strategy: retry
Validate before calling
const VALID_AREAS = new Set(['000000','020000',...]); // only pass recognized area codes
if (jobArea && !VALID_AREAS.has(jobArea)) throw new Error('unknown jobArea code'); Type guard
const isApiOk = (d) => d != null && (d.status === '1' || d.status === 1);
Try / catch
try {
return await cli.hot({ jobArea, sortType, page });
} catch (e) {
if (e.code === 'API_ERROR') {
console.error('51job API:', e.message); // includes upstream message
await sleep(3000 * attempt);
return cli.hot({ jobArea, sortType, page });
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Passing an unsupported area/sortType code; heavy scraping triggering rate limiting; 51job API version change altering the response envelope; requesting during maintenance windows.
Related errors
- API_ERROR
- HTTP ${result.httpStatus} from /api/user
- ${batch.error}
- Suno generate failed (HTTP ${status}): ${detail}
- TikTok Studio item_list failed: ${detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/28fafbbed9f8f70f.
Report an issue: GitHub.