jackwener/OpenCLI · warning · EmptyResultError

boss chatmsg

Error message

boss chatmsg

What it means

After fetchGeekHistoryMsg obtains a valid messages array, it throws EmptyResultError('boss chatmsg', ...) when that array is empty — Boss responded correctly but holds zero messages for this chat. Callers should treat this as 'no data' rather than a failure of the request itself.

Source

Thrown at clis/boss/utils.js:475

    const enriched = await fetchGeekFriendInfoList(page, [candidate.friendId]);
    return { ...candidate, ...(enriched[0] || {}) };
}
/**
 * Fetch message history for a geek-side chat.
 * friend must have .uid (boss's numeric id) and .securityId.
 */
export async function fetchGeekHistoryMsg(page, friend, opts = {}) {
    const pageNum = opts.page ?? 1;
    const bossId = friend.uid;
    const securityId = encodeURIComponent(friend.securityId || '');
    const url = `https://${BOSS_DOMAIN}/wapi/zpchat/geek/historyMsg?bossId=${bossId}&securityId=${securityId}&page=${pageNum}&c=20&src=0`;
    const data = await bossFetch(page, url);
    const messages = data.zpData?.messages ?? data.zpData?.historyMsgList;
    if (!Array.isArray(messages)) {
        throw new CommandExecutionError('Boss geek 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;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Skip this friend/chat — empty history is expected, not a bug
  2. Catch EmptyResultError in your loop and continue to the next chat
  3. If messages are expected, verify you are querying the correct friend (uid/securityId pair)
  4. Check the other party hasn't withdrawn/deleted all messages

Example fix

// before
const msgs = await messages(page, friend);
// after
let msgs;
try { msgs = await messages(page, friend); }
catch (e) { if (e instanceof EmptyResultError) { msgs = []; } else throw e; }
Defensive patterns

Strategy: try-catch

Validate before calling

// no pre-call validation possible; empty is a server-side fact — handle it after the call

Type guard

null

Try / catch

try { const msgs = await messages(page, friend); }
catch (e) {
  if (e instanceof EmptyResultError) continue; // skip chats with no history
  throw e;
}

Prevention

When it happens

Trigger: Calling messages for a chat that exists but has no history (never exchanged messages, history purged, or filtered to page 1 with nothing stored).

Common situations: Batch-exporting messages across all friends where some chats are empty; newly added contact with no conversation; account where history was cleared.

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/1ddf59540c2fa528. Report an issue: GitHub.