{"record":{"id":"b3abd190d215738c","repo":"jackwener/OpenCLI","slug":"xiaohongshu-ask-returned-a-malformed-page-payload-b3abd1","errorCode":null,"errorMessage":"xiaohongshu ask returned a malformed page payload: missing answer","messagePattern":"xiaohongshu ask returned a malformed page payload: missing answer","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/ask.js","lineNumber":383,"sourceCode":"    if (error === 'answer_timeout') {\n        throw new TimeoutError('xiaohongshu ask', timeoutSeconds, '点点没有在超时时间内返回答案；可以重试或提高 --timeout。');\n    }\n    if (error === 'send_message_failed') {\n        throw new AuthRequiredError(XHS_WEB_HOST, 'Xiaohongshu 点点 did not accept the query. Check login status for www.xiaohongshu.com.');\n    }\n    throw new CommandExecutionError(\n        `xiaohongshu ask failed: ${error || 'unknown error'}`,\n        raw?.page_url ? `Page URL: ${raw.page_url}` : undefined,\n    );\n}\n\nfunction requireAskPayload(raw) {\n    if (!raw || typeof raw !== 'object') {\n        throw new CommandExecutionError('xiaohongshu ask returned a malformed page payload');\n    }\n    const answer = cleanText(raw.answer || raw.base_info?.text || '');\n    if (!answer) {\n        throw new CommandExecutionError('xiaohongshu ask returned a malformed page payload: missing answer');\n    }\n    if (!compactSingleLine(raw.message_id) || !compactSingleLine(raw.conversation_id)) {\n        throw new CommandExecutionError('xiaohongshu ask returned a malformed page payload: missing message identity');\n    }\n}\n\nexport const command = cli({\n    site: 'xiaohongshu',\n    name: 'ask',\n    access: 'write',\n    description: 'Ask 小红书点点 and return the answer with citation sources.',\n    domain: XHS_WEB_HOST,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    navigateBefore: false,\n    args: [\n        { name: 'query', positional: true, required: true, help: 'Question for 点点' },\n        { name: 'timeout', type: 'int', default: 90, help: 'Seconds to wait for the 点点 answer' },","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/ask.js#L365-L401","documentation":"requireAskPayload throws this when the returned object exists but has no usable answer text: cleanText(raw.answer || raw.base_info?.text) is empty. The page responded but 点点 did not produce (or the script did not extract) an answer body, so the library refuses to return a hollow result.","triggerScenarios":"raw is an object whose answer and base_info.text are both missing/empty/whitespace after cleanText — e.g. the answer was still streaming, or XHS rendered the reply in a DOM node the selector no longer matches.","commonSituations":"Query sent but 点点 hasn't replied within the polling window (answer still empty); XHS redesigned the answer DOM so extraction finds nothing; the reply was removed/filtered; account restrictions suppress AI replies.","solutions":["Increase --timeout so the script polls longer for 点点's reply.","Retry the command; the first attempt may have raced the reply rendering.","Re-login to rule out restricted-account behavior.","Update the library if the XHS answer DOM changed.","Test with a different/simpler query to see whether replies render at all."],"exampleFix":"// before\nawait cli.run(['xiaohongshu','ask','--query','...','--timeout','15']);\n// after\nawait cli.run(['xiaohongshu','ask','--query','...','--timeout','60']);","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await xiaohongshuAsk({ query, timeout: 60 });\n} catch (e) {\n  if (/missing answer/.test(e.message)) {\n    await sleep(3000);\n    return xiaohongshuAsk({ query, timeout: 60 }); // reply may render late\n  }\n  throw e;\n}","preventionTips":["Use a generous --timeout so 点点's reply has time to render.","Avoid firing queries immediately after page load; let the chat initialize.","Test with simple queries if answers consistently come back empty.","Update extraction logic/library when the answer DOM changes."],"tags":["xiaohongshu","page-scraping","empty-response","automation"],"backgroundTag":"malformed-scrape-payload","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}