jackwener/OpenCLI · error · CommandExecutionError
Xianyu search request failed: ${result.error}
Error message
Xianyu search request failed: ${result.error} What it means
If the mtop response contains an error not classified as session-expiry, blocked, or mtop-not-ready, the CLI surfaces it as a CommandExecutionError. The message prefers the server's error_message and falls back to 'Xianyu search request failed: <result.error>'.
Source
Thrown at clis/xianyu/search.js:242
if (result?.error === 'auth-required') {
throw new AuthRequiredError('www.goofish.com', 'Xianyu search requires a logged-in browser session');
}
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,View on GitHub (pinned to 49907e53dc)
Solutions
- Read the surfaced error_message to identify the server-reported cause
- Retry after a short delay for transient FAIL_SYS_* gateway errors
- Simplify the query/filters (remove province/city or price bounds) to rule out param issues
- Update the library if the error persists (API surface may have changed)
Defensive patterns
Strategy: try-catch
Try / catch
try { await xianyuSearch(args); } catch (e) { if (e instanceof CommandExecutionError && /request failed/.test(e.message)) { console.error(e.message); await backoff(); return xianyuSearch(simplifiedArgs); } throw e; } Prevention
- Log the surfaced error_message for diagnosis before retrying
- Retry transient FAIL_SYS_* errors with backoff
- Reduce filters/query complexity when a persistent server error appears
- Keep the library updated for new Xianyu error codes
When it happens
Trigger: result.error is truthy with an unrecognized code — e.g. mtop system errors (FAIL_SYS_* not session-related), API param errors, or server-side business errors returned by the search API.
Common situations: Xianyu API changes introducing new error codes, transient server-side failures (FAIL_SYS_FLOW / gateway errors), unusual query strings rejected by the API.
Related errors
- 闲鱼商品详情接口未返回有效数据
- errorMessage || `Xianyu item detail request failed: ${result
- ${probe.detail}
- Bilibili creator comparison API failed: ${message} (${payloa
- 获取视频分P信息失败: ${payload?.message ?? 'unknown'} (${payload?.cod
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7140069da9430ec3.
Report an issue: GitHub.