{"record":{"id":"794e989b2cf1df76","repo":"jackwener/OpenCLI","slug":"xiaohongshu-did-not-accept-the-query-check-log","errorCode":null,"errorMessage":"Xiaohongshu 点点 did not accept the query. Check login status for www.xiaohongshu.com.","messagePattern":"Xiaohongshu 点点 did not accept the query\\. Check login status for www\\.xiaohongshu\\.com\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/ask.js","lineNumber":369,"sourceCode":"          };\n        }\n      })()\n    `;\n}\n\nfunction requirePrompt(query) {\n    const prompt = String(query || '').trim();\n    if (!prompt) throw new ArgumentError('query is required');\n    return prompt;\n}\n\nfunction mapAskError(raw, timeoutSeconds) {\n    const error = compactSingleLine(raw?.error);\n    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    }","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/ask.js#L351-L387","documentation":"This error is thrown by mapAskError when the Xiaohongshu ask command's in-page script reports error === 'send_message_failed', meaning the query could not be delivered to 点点 (Xiaohongshu's AI assistant) inside the logged-in browser page. The library maps this specific failure to AuthRequiredError because in practice the most common cause is an expired or missing login session on www.xiaohongshu.com. It tells the developer to re-authenticate before retrying.","triggerScenarios":"page.evaluate(buildAskEvaluateJs(...)) returns {ok:false, error:'send_message_failed'} — the page-side script failed to send the query to the 点点 chat, and mapAskError converts it to AuthRequiredError(XHS_WEB_HOST, ...).","commonSituations":"Session cookies for www.xiaohongshu.com expired or were cleared; the user is logged out; XHS flags the automated browser and rejects the message send; the conversation endpoint changed server-side so the send action fails.","solutions":["Run the xiaohongshu login flow (or the site auth command) to refresh the www.xiaohongshu.com session, then retry the ask command.","Open www.xiaohongshu.com in the controlled browser and verify you can manually send a message to 点点.","Retry with a longer --timeout in case the send timed out transiently.","Capture raw.page_url / page state and check whether XHS redirected to a login or verification page.","Update the library in case the XHS send-message DOM/API changed."],"exampleFix":"// before\nawait cli.run(['xiaohongshu','ask','--query','...']); // fails if session expired\n// after\nawait cli.run(['xiaohongshu','login']);               // refresh session first\nawait cli.run(['xiaohongshu','ask','--query','...']);","handlingStrategy":"try-catch","validationCode":"// before calling ask, ensure session exists\nif (!(await hasXhsSessionCookies(page))) await runXhsLogin();","typeGuard":null,"tryCatchPattern":"try {\n  await xiaohongshuAsk({ query });\n} catch (e) {\n  if (e instanceof AuthRequiredError || /login status/.test(e.message)) {\n    await runXhsLogin();\n    return xiaohongshuAsk({ query });\n  }\n  throw e;\n}","preventionTips":["Refresh the XHS session (login) before long-running automation batches.","Detect login-page redirects on www.xiaohongshu.com and re-auth proactively.","Persist and reuse a validated browser profile so cookies survive restarts.","Monitor AuthRequiredError occurrences as a signal to rotate/refresh sessions."],"tags":["auth","xiaohongshu","session-expired","automation"],"backgroundTag":"auth-required-login-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}