{"record":{"id":"19a0cab0a5872749","repo":"jackwener/OpenCLI","slug":"xiaohongshu-ask-returned-a-malformed-page-payload-19a0ca","errorCode":null,"errorMessage":"xiaohongshu ask returned a malformed page payload: missing message identity","messagePattern":"xiaohongshu ask returned a malformed page payload: missing message identity","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/ask.js","lineNumber":386,"sourceCode":"    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' },\n        { name: 'source-limit', type: 'int', default: 10, help: 'Maximum citation sources to return' },\n    ],\n    columns: ASK_COLUMNS,","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/ask.js#L368-L404","documentation":"requireAskPayload throws this when the payload has an answer but lacks a parseable message_id or conversation_id. The library requires both IDs to identify the ask exchange (e.g. for follow-up questions); without them the result would be unusable, so it fails fast.","triggerScenarios":"raw.answer is non-empty but compactSingleLine(raw.message_id) or compactSingleLine(raw.conversation_id) is falsy — the script extracted text but not the message metadata from the XHS conversation.","commonSituations":"XHS changed the DOM attributes carrying message/conversation IDs; the reply rendered before IDs were attached to the DOM; a redesigned conversation view omits the elements the script reads.","solutions":["Retry — IDs may attach to the DOM slightly after the text appears; a longer --timeout helps.","Update the library so the extraction script matches the current XHS DOM.","Re-login if the conversation view behaves differently for the session.","Log raw (minus sensitive text) to confirm which ID field is missing.","Fall back to answer-only consumption if you don't need follow-ups."],"exampleFix":"// before\nconst res = await xiaohongshuAsk({ query }); // requires message_id for follow-ups\n// after\ntry {\n  const res = await xiaohongshuAsk({ query });\n} catch (e) {\n  if (String(e.message).includes('missing message identity')) {\n    return { answer: e.answer ?? null }; // degrade gracefully when IDs absent\n  }\n  throw e;\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"function hasMessageIdentity(p) {\n  return typeof p.message_id === 'string' && p.message_id.length > 0 &&\n         typeof p.conversation_id === 'string' && p.conversation_id.length > 0;\n}","tryCatchPattern":"try {\n  return await xiaohongshuAsk({ query });\n} catch (e) {\n  if (/missing message identity/.test(e.message) && !needFollowUps) {\n    return { answer: null, degraded: true }; // proceed without follow-up support\n  }\n  throw e;\n}","preventionTips":["Only require message identity if you need follow-up questions.","Retry with longer timeout when IDs attach to the DOM late.","Track XHS DOM changes that strip message metadata attributes.","Update the library when this error starts appearing consistently."],"tags":["xiaohongshu","page-scraping","malformed-payload","automation"],"backgroundTag":"malformed-scrape-payload","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}