{"record":{"id":"67fec4a3aaee63ec","repo":"jackwener/OpenCLI","slug":"boss-candidate-search","errorCode":null,"errorMessage":"boss candidate search","messagePattern":"boss candidate search","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/boss/mark.js","lineNumber":55,"sourceCode":"            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 ? '✅ 标签已移除' : '✅ 标签已添加',\n                detail: `${friendName}: ${remove ? '移除' : '添加'}标签「${labelName}」`,\n            }];\n    },\n});\n","sourceCodeStart":37,"sourceCodeEnd":71,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/mark.js#L37-L71","documentation":"After the label is resolved, `opencli boss mark` locates the candidate with findFriendByUid; if absent it throws EmptyResultError('boss candidate search'), signaling the command produced no result row because the candidate does not exist in the chat/greet lists. EmptyResultError is the library's structured 'search yielded nothing' error rather than a generic Error.","triggerScenarios":"`opencli boss mark <uid> --label <label>` where the uid doesn't resolve in chat list or greet list: stale uid, deleted/archived chat, typo, or candidate beyond the scanned pages.","commonSituations":"Marking candidates from old session data after chats were cleaned up; uid copy errors; BOSS re-encryption of ids across sessions; candidate never greeted.","solutions":["Get a fresh uid from `opencli boss recommend` and retry.","Verify the candidate exists in the BOSS chat/greet list in the browser.","Re-check the uid for typos/truncation.","Re-greet the candidate to create a list entry, then mark them."],"exampleFix":"// before\nopencli boss mark <stale-uid> --label 沟通中\n// after\nopencli boss recommend\nopencli boss mark <fresh-uid> --label 沟通中","handlingStrategy":"try-catch","validationCode":"const uid = args.uid;\nif (!uid || typeof uid !== 'string' || uid.trim() === '') {\n  throw new Error('uid is required; obtain it from `opencli boss recommend`.');\n}","typeGuard":"function isValidUid(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await run(['opencli', 'boss', 'mark', uid, '--label', label]);\n} catch (e) {\n  if (e.name === 'EmptyResultError' || e.message.includes('boss candidate search')) {\n    console.error('Candidate not found; refresh uid via `opencli boss recommend`.');\n  }\n  throw e;\n}","preventionTips":["Source uids from a fresh recommend run each session.","Confirm the candidate is in the chat/greet list before marking.","Check uids for truncation when storing/passing.","Handle EmptyResultError distinctly from ArgumentError in tooling."],"tags":["empty-result","candidate-not-found","boss","chat-list"],"backgroundTag":"entity-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}