jackwener/OpenCLI · error · EmptyResultError

boss candidate search

Error message

boss candidate search

What it means

EmptyResultError raised by the boss send command when findFriendByUid cannot find any candidate matching kwargs.uid in the chat list after scanning up to 5 pages. The send flow aborts because it has no one to open a chat with.

Source

Thrown at clis/boss/send.js:29

    site: 'boss',
    name: 'send',
    access: 'write',
    description: 'BOSS直聘发送聊天消息',
    domain: 'www.zhipin.com',
    strategy: Strategy.COOKIE,
    navigateBefore: false,
    browser: true,
    args: [
        { name: 'uid', positional: true, required: true, help: 'Encrypted UID of the candidate (from chatlist)' },
        { name: 'text', required: true, positional: true, help: 'Message text to send' },
    ],
    columns: ['status', 'detail'],
    func: async (page, kwargs) => {
        requirePage(page);
        await navigateToChat(page, 3);
        const friend = await findFriendByUid(page, kwargs.uid, { maxPages: 5 });
        if (!friend)
            throw new EmptyResultError('boss candidate search', '请确认 uid 是否正确');
        const numericUid = friend.uid;
        const friendName = friend.name || '候选人';
        const clicked = await clickCandidateInList(page, numericUid);
        if (!clicked) {
            throw selectorError('聊天列表中的用户', '请确认聊天列表中有此人');
        }
        await page.wait({ time: 2 });
        const sent = await typeAndSendMessage(page, kwargs.text);
        if (!sent) {
            throw selectorError('消息输入框', '聊天页面 UI 可能已改变');
        }
        await page.wait({ time: 1 });
        return [{ status: '✅ 发送成功', detail: `已向 ${friendName} 发送: ${kwargs.text}` }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run candidate search / findFriendByUid to get a fresh, correct uid for this account
  2. Confirm the candidate actually appears in this account's chat list (a conversation exists)
  3. Increase maxPages beyond 5 if the candidate is deep in a long chat list
  4. Clear stale uid caches and refetch
  5. Log in with the correct account that owns the conversation

Example fix

// before
await cli('boss', 'send', { uid: cachedUid, message: 'hi' }); // stale uid
// after
const friends = await findFriendByUid(page, candidateNameOrUid, { maxPages: 5 });
if (!friends) throw new Error('candidate not in chat list; re-search candidates first');
await cli('boss', 'send', { uid: friends.uid, message: 'hi' });
Defensive patterns

Strategy: validation

Validate before calling

const friend = await findFriendByUid(page, uid, { maxPages: 5 });
if (!friend) throw new Error(`uid ${uid} not in chat list; refresh uids or increase maxPages`);

Type guard

function hasFriend(f) { return Boolean(f && f.uid && typeof f.uid === 'string'); }

Try / catch

try {
  await cli('boss', 'send', { uid, message });
} catch (e) {
  if (e.name === 'EmptyResultError') {
    await refreshChatList(page);
    return cli('boss', 'send', { uid, message });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling boss send with an incorrect/typo'd uid, a uid for a candidate with no existing conversation, or a uid from a different account's data; chat list pagination exhausted without a match.

Common situations: Reusing uids cached from a previous session after conversations were deleted; hardcoding uids from another recruiter account; uid format changes from BOSS; searching while the chat list is filtered.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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