jackwener/OpenCLI · error · CliError
INVALID_ARGUMENT
INVALID_ARGUMENT
Error message
keyword is required
What it means
The 51job search command requires a non-empty keyword; when kwargs.keyword is missing, null, or whitespace-only after trim, it throws CliError('INVALID_ARGUMENT') before any navigation. Pure client-side input validation.
Source
Thrown at clis/51job/search.js:45
browser: true,
navigateBefore: false,
args: [
{ name: 'keyword', type: 'string', required: true, positional: true, help: '搜索关键词(岗位名 / 技能 / 公司)' },
{ name: 'area', type: 'string', default: '全国', help: '城市名或 6 位城市码(如 "杭州" / "080200" / "全国")' },
{ name: 'salary', type: 'string', default: '', help: '薪资区间(如 "10-15k" / "1-1.5万" / "20-30k")' },
{ name: 'experience', type: 'string', default: '', help: '工作年限(如 "应届" / "1-3年" / "3-5年" / "5-7年")' },
{ name: 'degree', type: 'string', default: '', help: '学历要求(如 "本科" / "大专" / "硕士")' },
{ name: 'companyType', type: 'string', default: '', help: '公司性质(如 "外资" / "国企" / "民营")' },
{ name: 'companySize', type: 'string', default: '', help: '公司规模(如 "50-150" / "1000-5000")' },
{ name: 'sort', type: 'string', default: '综合', help: '排序:综合 / 最新 / 薪资 / 距离' },
{ name: 'page', type: 'int', default: 1, help: '页码(1-based)' },
{ name: 'limit', type: 'int', default: 20, help: '返回条数(1-50)' },
],
columns: SEARCH_COLUMNS,
func: async (page, kwargs) => {
requirePage(page);
const keyword = String(kwargs.keyword ?? '').trim();
if (!keyword) throw new CliError('INVALID_ARGUMENT', 'keyword is required');
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 salary = resolveCode(kwargs.salary, SALARY_CODES);
const workYear = resolveCode(kwargs.experience, WORKYEAR_CODES);
const degree = resolveCode(kwargs.degree, DEGREE_CODES);
const companyType = resolveCode(kwargs.companyType, COMPANY_TYPE_CODES);
const companySize = resolveCode(kwargs.companySize, COMPANY_SIZE_CODES);
const sortType = resolveCode(kwargs.sort, SORT_CODES, '0');
// Establish WAF-clean origin. Reusing the same tab avoids the slider
// challenge fire every call.
const currentUrl = await page.evaluate(`(() => window.location.href)()`);
if (!String(currentUrl).startsWith(WE_ORIGIN)) {
await navigateTo(page, `${WE_ORIGIN}/pc/search?keyword=${encodeURIComponent(keyword)}&searchType=2`, 2);
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Provide a non-empty keyword string in the call
- Trim/validate user input before invoking search
- Use the hot subcommand if you want recommendations without a keyword
- Fix the argument key name to exactly keyword
Example fix
// before
await cli.search({});
// after
const kw = (input.term || '').trim();
if (!kw) return cli.hot({}); // keyword-less → use hot
return cli.search({ keyword: kw }); Defensive patterns
Strategy: validation
Validate before calling
const keyword = String(input?.keyword ?? '').trim();
if (!keyword) throw new Error('keyword must be a non-empty string before search'); Type guard
const hasKeyword = (a) => a != null && String(a.keyword ?? '').trim() !== '';
Try / catch
try {
return await cli.search({ keyword });
} catch (e) {
if (e.code === 'INVALID_ARGUMENT') { console.warn('empty keyword'); return []; }
throw e;
} Prevention
- Trim and check keyword before every search call
- Route keyword-less use cases to the hot subcommand
- Guard UI/config inputs so empty terms never reach the call
- Use the exact argument name keyword
When it happens
Trigger: Calling the search subcommand without keyword, or with keyword: '' / undefined / ' ' (String(kwargs.keyword ?? '').trim() is empty) — thrown at clis/51job/search.js:45. Note: for keyword-less recommendations use the hot subcommand instead.
Common situations: Wiring search to a UI search box and submitting empty; config-driven runs where the keyword key is misspelled or unset; upstream pipeline dropping the term; intending hot-list behavior but calling search with no keyword.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- Unknown privacy "${privacy}". Valid: ${PRIVACY.join(', ')}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c2967fea915b05d4.
Report an issue: GitHub.