jackwener/OpenCLI · error · EmptyResultError

boss candidate search

Error message

boss candidate search

What it means

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.

Source

Thrown at clis/boss/mark.js:55

            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 ? '✅ 标签已移除' : '✅ 标签已添加',
                detail: `${friendName}: ${remove ? '移除' : '添加'}标签「${labelName}」`,
            }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Get a fresh uid from `opencli boss recommend` and retry.
  2. Verify the candidate exists in the BOSS chat/greet list in the browser.
  3. Re-check the uid for typos/truncation.
  4. Re-greet the candidate to create a list entry, then mark them.

Example fix

// before
opencli boss mark <stale-uid> --label 沟通中
// after
opencli boss recommend
opencli boss mark <fresh-uid> --label 沟通中
Defensive patterns

Strategy: try-catch

Validate before calling

const uid = args.uid;
if (!uid || typeof uid !== 'string' || uid.trim() === '') {
  throw new Error('uid is required; obtain it from `opencli boss recommend`.');
}

Type guard

function isValidUid(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  await run(['opencli', 'boss', 'mark', uid, '--label', label]);
} catch (e) {
  if (e.name === 'EmptyResultError' || e.message.includes('boss candidate search')) {
    console.error('Candidate not found; refresh uid via `opencli boss recommend`.');
  }
  throw e;
}

Prevention

When it happens

Trigger: `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.

Common situations: Marking candidates from old session data after chats were cleaned up; uid copy errors; BOSS re-encryption of ids across sessions; candidate never greeted.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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