jackwener/OpenCLI · info · EmptyResultError

Boss returned no messages for this chat.

Error message

Boss returned no messages for this chat.

What it means

bossChatMsg throws EmptyResultError('boss chatmsg', 'Boss returned no messages for this chat.') when the historyMsg API responds correctly with a message list, but the array is empty for the requested page. This is a legitimate empty result: the conversation exists (securityId was found) yet no messages were returned — most commonly because the requested page exceeds the number of available pages.

Source

Thrown at clis/boss/chatmsg.js:52

            JSON.stringify(m.body || {}).slice(0, 120),
        time: m.time ? new Date(m.time).toLocaleString('zh-CN') : '',
    };
}

async function bossChatMsg(page, kwargs, existingFriend) {
    const friend = existingFriend ?? await findFriendByUid(page, kwargs.uid);
    if (!friend) throw new EmptyResultError('boss chatmsg', '未找到该候选人');
    if (!friend.securityId) throw new CommandExecutionError('该聊天缺少 securityId,无法获取历史消息');
    const gid = friend.uid;
    const securityId = encodeURIComponent(friend.securityId);
    const msgUrl = `https://www.zhipin.com/wapi/zpchat/boss/historyMsg?gid=${gid}&securityId=${securityId}&page=${kwargs.page}&c=20&src=0`;
    const msgData = await bossFetch(page, msgUrl);
    const messages = msgData.zpData?.messages ?? msgData.zpData?.historyMsgList;
    if (!Array.isArray(messages)) {
        throw new CommandExecutionError('Boss recruiter history response did not include a message list');
    }
    if (messages.length === 0) {
        throw new EmptyResultError('boss chatmsg', 'Boss returned no messages for this chat.');
    }
    return messages.map((m) => mapBossMsg(m, friend));
}

async function geekChatMsg(page, kwargs, encryptSystemId) {
    const friend = await findGeekFriendByUid(page, kwargs.uid, { encryptSystemId });
    if (!friend) throw new EmptyResultError('boss chatmsg', '未找到该聊天(geek 侧)');
    if (!friend.securityId) throw new CommandExecutionError('该聊天缺少 securityId,无法获取历史消息');
    const messages = await fetchGeekHistoryMsg(page, friend, { page: kwargs.page });
    return messages.map((m) => mapGeekMsg(m, friend));
}

cli({
    site: 'boss',
    name: 'chatmsg',
    access: 'read',
    description: 'BOSS直聘查看聊天消息历史(招聘端/求职端)',
    domain: 'www.zhipin.com',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use --page 1 (the default); only increase the page while the previous page returned rows.
  2. Treat this error as the end-of-pagination signal when iterating history pages.
  3. If page=1 is also empty, verify the conversation actually has messages in the BOSS web UI.
  4. Try side=geek (auto mode) — boss-side history may be cleared while geek-side messages remain.
  5. Check that the right uid was passed; a fresh chat with no replies returns an empty list.

Example fix

// before
for (let p = 1; ; p++) {
  const rows = await chatmsg(uid, { page: p }); // throws at end
}
// after
for (let p = 1; ; p++) {
  try {
    const rows = await chatmsg(uid, { page: p });
    all.push(...rows);
  } catch (e) {
    if (isEmptyResultError(e)) break; // end of history
    throw e;
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// stop paginating when a page returns fewer than the page size (20)
if (lastPage.length < 20) return all; // no more pages — don't request the next one

Type guard

null

Try / catch

try {
  const msgs = await chatmsg(uid, { page: n });
} catch (e) {
  if (isEmptyResultError(e) && /no messages/i.test(e.message)) return []; // end of history
  throw e;
}

Prevention

When it happens

Trigger: Calling `boss chatmsg <uid> --page N` where N is beyond the last page of history (20 messages per page), or a conversation where messages exist only on the geek side / were fully deleted.

Common situations: Paginating in a loop until this error to detect end-of-history (expected behavior); fetching page 2 of a chat with fewer than 21 messages; messages purged by BOSS retention policy or the candidate clearing the conversation.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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