{"record":{"id":"1ddf59540c2fa528","repo":"jackwener/OpenCLI","slug":"boss-chatmsg","errorCode":null,"errorMessage":"boss chatmsg","messagePattern":"boss chatmsg","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/boss/utils.js","lineNumber":475,"sourceCode":"    const enriched = await fetchGeekFriendInfoList(page, [candidate.friendId]);\n    return { ...candidate, ...(enriched[0] || {}) };\n}\n/**\n * Fetch message history for a geek-side chat.\n * friend must have .uid (boss's numeric id) and .securityId.\n */\nexport async function fetchGeekHistoryMsg(page, friend, opts = {}) {\n    const pageNum = opts.page ?? 1;\n    const bossId = friend.uid;\n    const securityId = encodeURIComponent(friend.securityId || '');\n    const url = `https://${BOSS_DOMAIN}/wapi/zpchat/geek/historyMsg?bossId=${bossId}&securityId=${securityId}&page=${pageNum}&c=20&src=0`;\n    const data = await bossFetch(page, url);\n    const messages = data.zpData?.messages ?? data.zpData?.historyMsgList;\n    if (!Array.isArray(messages)) {\n        throw new CommandExecutionError('Boss geek history response did not include a message list');\n    }\n    if (messages.length === 0) {\n        throw new EmptyResultError('boss chatmsg', 'Boss returned no messages for this chat.');\n    }\n    return messages;\n}\n","sourceCodeStart":457,"sourceCodeEnd":479,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/utils.js#L457-L479","documentation":"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.","triggerScenarios":"Calling messages for a chat that exists but has no history (never exchanged messages, history purged, or filtered to page 1 with nothing stored).","commonSituations":"Batch-exporting messages across all friends where some chats are empty; newly added contact with no conversation; account where history was cleared.","solutions":["Skip this friend/chat — empty history is expected, not a bug","Catch EmptyResultError in your loop and continue to the next chat","If messages are expected, verify you are querying the correct friend (uid/securityId pair)","Check the other party hasn't withdrawn/deleted all messages"],"exampleFix":"// before\nconst msgs = await messages(page, friend);\n// after\nlet msgs;\ntry { msgs = await messages(page, friend); }\ncatch (e) { if (e instanceof EmptyResultError) { msgs = []; } else throw e; }","handlingStrategy":"try-catch","validationCode":"// no pre-call validation possible; empty is a server-side fact — handle it after the call","typeGuard":"null","tryCatchPattern":"try { const msgs = await messages(page, friend); }\ncatch (e) {\n  if (e instanceof EmptyResultError) continue; // skip chats with no history\n  throw e;\n}","preventionTips":["Treat EmptyResultError as a skip signal in batch exports, not a failure","Filter friends to those with recent activity before exporting messages","Distinguish EmptyResultError from CommandExecutionError in your catch logic","Never retry on EmptyResultError — the result will stay empty"],"tags":["boss-zhipin","empty-result","chat-history"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}