jackwener/OpenCLI · error · CommandExecutionError
Xianyu messages returned malformed message list
Error message
Xianyu messages returned malformed message list
What it means
After in-page extraction, the CLI expects state.messages to be an array. If the evaluated object comes back without a messages array (page structure changed, extraction partially failed, or a non-standard page state was captured), CommandExecutionError('Xianyu messages returned malformed message list') is thrown at clis/xianyu/messages.js:68. This is a defensive check against malformed automation output, not an API business error.
Source
Thrown at clis/xianyu/messages.js:68
if (hasIds) {
url = buildChatUrl(itemId, userId);
await page.goto(url);
} else {
if (!page.getCurrentUrl || !/https:\/\/www\.goofish\.com\/im\b/.test(await page.getCurrentUrl())) {
await page.goto('https://www.goofish.com/im');
}
}
await page.wait(2);
if (rank > 0) {
requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rank - 1)), 'messages rank click');
await page.wait(2);
}
const state = requireEvaluateObject(await page.evaluate(buildExtractChatStateEvaluate(limit)), 'messages');
if (state?.requiresAuth) {
throw new AuthRequiredError('www.goofish.com', 'Xianyu messages requires a logged-in browser session');
}
if (!Array.isArray(state.messages)) {
throw new CommandExecutionError('Xianyu messages returned malformed message list');
}
const messages = state.messages;
if (!messages.length) {
throw new EmptyResultError('xianyu messages', 'No visible messages were found in this Xianyu conversation');
}
return messages.slice(-limit).map((message, index) => ({
index: index + 1,
peer_name: state.peer_name || '',
item_title: state.item_title || '',
message: message.text || '',
item_id: itemId,
peer_user_id: userId,
url: url || '',
}));
},
});
export const __test__ = {View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the command once — a slow/mid-render page is the most frequent benign cause.
- Update the CLI/library to the latest version, since Goofish DOM changes are usually patched upstream.
- Verify the target conversation opens normally in the browser (not a captcha or error page).
- Increase wait time before extraction so the chat fully renders.
- Inspect the saved page state/screenshot; if the DOM changed, report or patch the extraction script.
Example fix
// before: one malformed page aborts a batch sync
for (const c of convs) await fetchMessages(c);
// after
for (const c of convs) {
try { await fetchMessages(c); }
catch (e) {
if (e instanceof CommandExecutionError && /malformed/.test(e.message)) { failures.push(c); continue; }
throw e;
}
} Defensive patterns
Strategy: retry
Type guard
function isWellFormedChatState(s) { return s != null && typeof s === 'object' && Array.isArray(s.messages); } Try / catch
let last;
for (let i = 0; i < 3; i++) {
try { return await fetchMessages(target); }
catch (e) { last = e; if (e instanceof CommandExecutionError) { await sleep(2000 * (i + 1)); continue; } throw e; }
}
throw last; Prevention
- Keep the CLI updated — Goofish DOM changes break extraction selectors.
- Wait for the chat to fully render before extraction.
- Verify targeted conversations open normally (no captcha/interstitial).
- Capture a screenshot/page dump on failure for diagnosis.
When it happens
Trigger: The buildExtractChatStateEvaluate script runs on a page whose DOM does not match expectations — e.g. an interstitial, a chat page still loading, a page variant after a Goofish front-end update, or the evaluate returning an object lacking the messages key.
Common situations: Goofish shipped a DOM/UI change that broke the extraction selectors; hitting a non-chat page because rank/index targeting landed on the wrong conversation; slow page load so state was captured mid-render; library version drift between CLI and site markup.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Ctrip package DOM extraction returned malformed rows
- Ctrip tour DOM extraction returned malformed rows
- Failed to fetch Barchart greeks for ${symbol}
- Failed to extract Booking.com cards: ${err?.message || err}
- Booking.com page returned no extractable data
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a4f31a45ab2e000c.
Report an issue: GitHub.