{"record":{"id":"00fe96708895c20a","repo":"jackwener/OpenCLI","slug":"labelinput-object-keys-label-map","errorCode":null,"errorMessage":"未知标签: ${labelInput}。可用标签: ${Object.keys(LABEL_MAP).join(', ')}","messagePattern":"未知标签: (.+?)。可用标签: (.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/boss/mark.js","lineNumber":48,"sourceCode":"    func: async (page, kwargs) => {\n        requirePage(page);\n        const labelInput = kwargs.label;\n        const remove = kwargs.remove || false;\n        // Resolve label to ID\n        let labelId;\n        if (LABEL_MAP[labelInput]) {\n            labelId = LABEL_MAP[labelInput];\n        }\n        else if (!isNaN(Number(labelInput))) {\n            labelId = Number(labelInput);\n        }\n        else {\n            const entry = Object.entries(LABEL_MAP).find(([k]) => k.includes(labelInput));\n            if (entry) {\n                labelId = entry[1];\n            }\n            else {\n                throw new ArgumentError(`未知标签: ${labelInput}。可用标签: ${Object.keys(LABEL_MAP).join(', ')}`);\n            }\n        }\n        verbose(`${remove ? 'Removing' : 'Adding'} label ${labelId} for ${kwargs.uid}...`);\n        await navigateToChat(page);\n        const friend = await findFriendByUid(page, kwargs.uid, { checkGreetList: true });\n        if (!friend)\n            throw new EmptyResultError('boss candidate search');\n        const friendName = friend.name || '候选人';\n        const action = remove ? 'deleteMark' : 'addMark';\n        const params = new URLSearchParams({\n            friendId: String(friend.uid),\n            friendSource: String(friend.friendSource ?? 0),\n            labelId: String(labelId),\n        });\n        await bossFetch(page, `https://www.zhipin.com/wapi/zprelation/friend/label/${action}?${params.toString()}`);\n        const labelName = Object.entries(LABEL_MAP).find(([, v]) => v === labelId)?.[0] || String(labelId);\n        return [{\n                status: remove ? '✅ 标签已移除' : '✅ 标签已添加',","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/mark.js#L30-L66","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the exact listed labels: 新招呼, 沟通中, 已约面, 已获取简历, 已交换电话, 已交换微信, 不合适, 牛人发起, 收藏.","Alternatively pass the numeric label ID (1,2,3,4,5,6,7,8,11).","Use a substring of the label such as '已约' for '已约面'.","Ensure your terminal passes UTF-8 correctly (LANG/LC_ALL with UTF-8) so Chinese args aren't mangled."],"exampleFix":"// before\nopencli boss mark <uid> --label interview\n// after\nopencli boss mark <uid> --label 已约面   # or --label 3","handlingStrategy":"validation","validationCode":"const LABELS = ['新招呼','沟通中','已约面','已获取简历','已交换电话','已交换微信','不合适','牛人发起','收藏'];\nconst IDS = new Set([1,2,3,4,5,6,7,8,11]);\nfunction assertValidLabel(l) {\n  const ok = LABELS.some(k => k.includes(l)) || IDS.has(Number(l));\n  if (!ok) throw new Error(`Unknown label \"${l}\"; use one of: ${LABELS.join(', ')} or IDs 1-8/11`);\n}","typeGuard":"function isKnownLabel(v) {\n  return typeof v === 'string' &&\n    (['新招呼','沟通中','已约面','已获取简历','已交换电话','已交换微信','不合适','牛人发起','收藏'].some(k => k.includes(v)) || !isNaN(Number(v)));\n}","tryCatchPattern":"try {\n  await run(['opencli', 'boss', 'mark', uid, '--label', label]);\n} catch (e) {\n  if (e.message.includes('未知标签')) {\n    console.error('Use an exact label name or numeric ID (1-8, 11).');\n  }\n  throw e;\n}","preventionTips":["Use exact Chinese label names or numeric IDs from the LABEL_MAP.","Prefer IDs (1-8, 11) in scripts to avoid encoding issues.","Ensure the terminal/shell passes UTF-8 (LANG=C.UTF-8) so Chinese args survive.","Remember substring matching is input-inside-label only, not label-inside-input."],"tags":["argument-validation","label-mapping","boss","i18n"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}