jackwener/OpenCLI · error · CommandExecutionError
xiaohongshu ask failed: ${error || 'unknown error'}
Error message
xiaohongshu ask failed: ${error || 'unknown error'} What it means
This is the catch-all CommandExecutionError from mapAskError: the ask page script returned an error value that is neither 'answer_timeout' nor 'send_message_failed', so the library wraps it into 'xiaohongshu ask failed: <error>' with the page URL as a hint. It signals an unrecognized failure mode of the in-page ask flow.
Source
Thrown at clis/xiaohongshu/ask.js:371
})()
`;
}
function requirePrompt(query) {
const prompt = String(query || '').trim();
if (!prompt) throw new ArgumentError('query is required');
return prompt;
}
function mapAskError(raw, timeoutSeconds) {
const error = compactSingleLine(raw?.error);
if (error === 'answer_timeout') {
throw new TimeoutError('xiaohongshu ask', timeoutSeconds, '点点没有在超时时间内返回答案;可以重试或提高 --timeout。');
}
if (error === 'send_message_failed') {
throw new AuthRequiredError(XHS_WEB_HOST, 'Xiaohongshu 点点 did not accept the query. Check login status for www.xiaohongshu.com.');
}
throw new CommandExecutionError(
`xiaohongshu ask failed: ${error || 'unknown error'}`,
raw?.page_url ? `Page URL: ${raw.page_url}` : undefined,
);
}
function requireAskPayload(raw) {
if (!raw || typeof raw !== 'object') {
throw new CommandExecutionError('xiaohongshu ask returned a malformed page payload');
}
const answer = cleanText(raw.answer || raw.base_info?.text || '');
if (!answer) {
throw new CommandExecutionError('xiaohongshu ask returned a malformed page payload: missing answer');
}
if (!compactSingleLine(raw.message_id) || !compactSingleLine(raw.conversation_id)) {
throw new CommandExecutionError('xiaohongshu ask returned a malformed page payload: missing message identity');
}
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the interpolated error string (and Page URL hint) to identify the actual failure cause.
- Retry the ask command — transient page issues often resolve.
- Re-run login to rule out session problems even though it wasn't classified as auth failure.
- Update the library if XHS changed its page behavior/error vocabulary.
- Inspect raw.page_url in the browser to see what state the page was in.
Example fix
// before
const res = await xiaohongshuAsk({ query });
// after
try {
const res = await xiaohongshuAsk({ query });
} catch (e) {
console.error('ask failed:', e.message); // includes unmapped XHS error
await xiaohongshuLogin();
return xiaohongshuAsk({ query });
} Defensive patterns
Strategy: retry
Try / catch
try {
return await xiaohongshuAsk({ query });
} catch (e) {
if (/xiaohongshu ask failed:/.test(e.message) && attempts < 3) {
await sleep(2000 * attempts);
return xiaohongshuAsk({ query });
}
throw e;
} Prevention
- Keep the library updated since XHS error codes can change without notice.
- Log the full unmapped error text and page_url for diagnosis.
- Retry transient failures with backoff before surfacing to users.
- Verify session health even for non-auth-classified failures.
When it happens
Trigger: raw.error is any falsy/unexpected value (e.g. undefined, 'unknown', a new XHS error code) and raw.ok === false causes mapAskError to fall through to the final throw.
Common situations: Xiaohongshu changed its front-end error codes after an update; the page returned an unexpected response shape; a transient network hiccup produced an unmapped error; a bug in the injected script yields no error field.
Related errors
- xiaohongshu ask returned a malformed page payload
- xiaohongshu ask returned a malformed page payload: missing a
- xiaohongshu ask returned a malformed page payload: missing m
- Xiaohongshu 点点 did not accept the query. Check login status
- Could not find ${fieldName} input. Debug screenshot: /tmp/xh
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/02d606cc522459fc.
Report an issue: GitHub.