jackwener/OpenCLI · error · CommandExecutionError
Xianyu search response did not include an items array
Error message
Xianyu search response did not include an items array
What it means
After error handling, the CLI requires result.items to be an array. If the successful-shaped response lacks an items array (null or a non-array), a CommandExecutionError is thrown, since the parser cannot map items into ranked results.
Source
Thrown at clis/xianyu/search.js:245
if (result?.error === 'blocked') {
throw new CommandExecutionError('Xianyu returned a verification page or blocked the current browser session');
}
if (result?.error === 'mtop-not-ready') {
throw selectorError('window.lib.mtop', '闲鱼页面未完成初始化,无法调用搜索接口');
}
if (!result || typeof result !== 'object') {
throw new CommandExecutionError('Xianyu search returned a malformed response');
}
const errorCode = String(result?.error_code || '');
const errorMessage = String(result?.error_message || '');
if (/FAIL_SYS_SESSION_EXPIRED|SESSION_EXPIRED|FAIL_SYS_TOKEN/.test(errorCode) || /FAIL_SYS_SESSION_EXPIRED|SESSION_EXPIRED/.test(errorMessage)) {
throw new AuthRequiredError('www.goofish.com', 'Xianyu search requires a logged-in browser session');
}
if (result?.error) {
throw new CommandExecutionError(errorMessage || `Xianyu search request failed: ${result.error}`);
}
if (!Array.isArray(result.items)) {
throw new CommandExecutionError('Xianyu search response did not include an items array');
}
const items = result.items;
if (!items.length) {
throw new EmptyResultError('xianyu search', '没有匹配的商品(筛选条件可能过窄,或当前关键词无结果)');
}
return items.map((item, index) => ({ rank: index + 1, ...item }));
},
});
export const __test__ = {
ROWS_PER_PAGE,
MAX_LIMIT,
normalizeLimit,
buildSearchUrl,
parsePriceArg,
buildSearchFilter,
buildExtraFilterValue,
};
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry once to rule out a transient malformed payload
- Update the library to a version matching the current Goofish response schema
- Report the issue with the keyword/filters used if it reproduces consistently
Defensive patterns
Strategy: retry
Try / catch
try { await xianyuSearch(args); } catch (e) { if (e instanceof CommandExecutionError && /items array/.test(e.message)) { await wait(3000); return xianyuSearch(args); } throw e; } Prevention
- Retry once on this error to rule out transient payload issues
- Update the library when goofish.com changes its response schema
- Report reproducible cases with the exact keyword and filters used
When it happens
Trigger: The in-page script returns an object without a valid items array — e.g. the response parser found no item list in the mtop payload because the API response shape changed or the parsed data node was missing.
Common situations: Goofish updating their mtop response schema (field renames/moves), edge-case responses (all-ads page, special result types) where the extractor fails to collect items.
Related errors
- ${command} parser returned an unexpected shape
- ${command} parser returned row ${index + 1} without required
- YouTube video metadata is missing membersOnly
- Zhihu search returned malformed data list
- Failed to parse 12306 station_name.js: source string not fou
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/30219f8d89b68d3d.
Report an issue: GitHub.