jackwener/OpenCLI · error · ArgumentError

未知标签: ${labelInput}。可用标签: ${Object.keys(LABEL_MAP).join(', '

Error message

未知标签: ${labelInput}。可用标签: ${Object.keys(LABEL_MAP).join(', ')}

What it means

`opencli boss mark` resolves the --label argument via LABEL_MAP (新招呼/沟通中/已约面/已获取简历/已交换电话/已交换微信/不合适/牛人发起/收藏). Exact match first, then numeric label ID, then a substring ('includes') match; if nothing matches, it throws this ArgumentError listing all valid labels. Note the substring match is one-directional: the input must appear inside a label name, not vice versa.

Source

Thrown at clis/boss/mark.js:48

    func: async (page, kwargs) => {
        requirePage(page);
        const labelInput = kwargs.label;
        const remove = kwargs.remove || false;
        // Resolve label to ID
        let labelId;
        if (LABEL_MAP[labelInput]) {
            labelId = LABEL_MAP[labelInput];
        }
        else if (!isNaN(Number(labelInput))) {
            labelId = Number(labelInput);
        }
        else {
            const entry = Object.entries(LABEL_MAP).find(([k]) => k.includes(labelInput));
            if (entry) {
                labelId = entry[1];
            }
            else {
                throw new ArgumentError(`未知标签: ${labelInput}。可用标签: ${Object.keys(LABEL_MAP).join(', ')}`);
            }
        }
        verbose(`${remove ? 'Removing' : 'Adding'} label ${labelId} for ${kwargs.uid}...`);
        await navigateToChat(page);
        const friend = await findFriendByUid(page, kwargs.uid, { checkGreetList: true });
        if (!friend)
            throw new EmptyResultError('boss candidate search');
        const friendName = friend.name || '候选人';
        const action = remove ? 'deleteMark' : 'addMark';
        const params = new URLSearchParams({
            friendId: String(friend.uid),
            friendSource: String(friend.friendSource ?? 0),
            labelId: String(labelId),
        });
        await bossFetch(page, `https://www.zhipin.com/wapi/zprelation/friend/label/${action}?${params.toString()}`);
        const labelName = Object.entries(LABEL_MAP).find(([, v]) => v === labelId)?.[0] || String(labelId);
        return [{
                status: remove ? '✅ 标签已移除' : '✅ 标签已添加',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use one of the exact listed labels: 新招呼, 沟通中, 已约面, 已获取简历, 已交换电话, 已交换微信, 不合适, 牛人发起, 收藏.
  2. Alternatively pass the numeric label ID (1,2,3,4,5,6,7,8,11).
  3. Use a substring of the label such as '已约' for '已约面'.
  4. Ensure your terminal passes UTF-8 correctly (LANG/LC_ALL with UTF-8) so Chinese args aren't mangled.

Example fix

// before
opencli boss mark <uid> --label interview
// after
opencli boss mark <uid> --label 已约面   # or --label 3
Defensive patterns

Strategy: validation

Validate before calling

const LABELS = ['新招呼','沟通中','已约面','已获取简历','已交换电话','已交换微信','不合适','牛人发起','收藏'];
const IDS = new Set([1,2,3,4,5,6,7,8,11]);
function assertValidLabel(l) {
  const ok = LABELS.some(k => k.includes(l)) || IDS.has(Number(l));
  if (!ok) throw new Error(`Unknown label "${l}"; use one of: ${LABELS.join(', ')} or IDs 1-8/11`);
}

Type guard

function isKnownLabel(v) {
  return typeof v === 'string' &&
    (['新招呼','沟通中','已约面','已获取简历','已交换电话','已交换微信','不合适','牛人发起','收藏'].some(k => k.includes(v)) || !isNaN(Number(v)));
}

Try / catch

try {
  await run(['opencli', 'boss', 'mark', uid, '--label', label]);
} catch (e) {
  if (e.message.includes('未知标签')) {
    console.error('Use an exact label name or numeric ID (1-8, 11).');
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing --label values like '已读', 'interview', '已约' works ('已约' is a substring of '已约面'), but '面' (label contains input fails), English names, wrong IDs (e.g. 99), or full-width variants of the Chinese labels throw this error.

Common situations: English-speaking users typing English label names; guessing a label ID outside 1-8/11; passing a label name from a different ATS tool; shell mangling of Chinese characters (encoding issues) so the string no longer equals the map keys.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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