jackwener/OpenCLI · error · ArgumentError

Invalid jobType: ${input}

Error message

Invalid jobType: ${input}

What it means

resolveJobType validates the jobType filter for BOSS search. Only the literals 全职, 兼职, 实习, 不限 (or their already-resolved numeric codes 1901/1903/1902/0) are accepted; any other value raises this ArgumentError. Empty/omitted input returns '' (no filter).

Source

Thrown at clis/boss/search.js:85

function resolveMap(input, map) {
    if (!input)
        return '';
    if (map[input] !== undefined)
        return map[input];
    for (const [key, val] of Object.entries(map)) {
        if (key.includes(input))
            return val;
    }
    return input;
}
function resolveJobType(input) {
    if (!input)
        return '';
    if (JOB_TYPE_MAP[input] !== undefined)
        return JOB_TYPE_MAP[input];
    if (JOB_TYPE_CODES.has(input))
        return input;
    throw new ArgumentError(`Invalid jobType: ${input}`, 'Use one of: 全职, 兼职, 实习, 不限');
}
function formatBossOnline(value) {
    if (value === true)
        return 'Y';
    if (value === false)
        return 'N';
    return '';
}
async function captureJobList(page, url) {
    if (typeof page.startNetworkCapture !== 'function' ||
        typeof page.readNetworkCapture !== 'function' ||
        !await page.startNetworkCapture('joblist.json')) {
        throw new CommandExecutionError('BOSS search requires CDP network capture');
    }
    await page.readNetworkCapture();
    for (let attempt = 0; attempt < 2; attempt++) {
        const separator = url.includes('?') ? '&' : '?';
        await navigateTo(page, `${url}${separator}_opencli=${Date.now()}`, 5);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use exactly one of: 全职, 兼职, 实习, 不限
  2. Or pass one of the valid numeric codes: 1901 (全职), 1903 (兼职), 1902 (实习), 0 (不限)
  3. Omit the jobType parameter entirely if no filter is wanted
  4. Cross-check JOB_TYPE_MAP in clis/boss/search.js for the accepted values

Example fix

// before
await cli('boss', 'search', { jobType: 'full-time' });
// after
await cli('boss', 'search', { jobType: '全职' });
Defensive patterns

Strategy: validation

Validate before calling

const JOB_TYPES = ['不限', '全职', '兼职', '实习'];
if (input !== undefined && input !== '' && !JOB_TYPES.includes(input)) {
  throw new Error(`jobType must be one of ${JOB_TYPES.join(', ')}`);
}

Type guard

const isJobType = (v) => typeof v === 'string' && ['不限','全职','兼职','实习','1901','1902','1903','0'].includes(v);

Try / catch

try {
  return await cli('boss', 'search', { jobType: input });
} catch (e) {
  if (String(e.message).startsWith('Invalid jobType')) {
    console.warn(`bad jobType "${input}"; searching without type filter`);
    return cli('boss', 'search', {});
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing jobType values like 'full-time', '正式', '合同工', or a numeric code not in JOB_TYPE_MAP to the jobType parameter of boss search.

Common situations: Translating enum values from another job API into this one; passing codes from a different BOSS enumeration; localization mistakes; assuming synonyms like '正式工' map automatically.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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