jackwener/OpenCLI · warning · EmptyResultError

没有匹配的商品(筛选条件可能过窄,或当前关键词无结果)

Error message

没有匹配的商品(筛选条件可能过窄,或当前关键词无结果)

What it means

The search executed successfully but returned zero items, so an EmptyResultError is thrown for 'xianyu search'. The hint notes filters may be too narrow or the keyword has no listings.

Source

Thrown at clis/xianyu/search.js:249

            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

  1. Broaden the query (use shorter, more generic keywords)
  2. Widen or remove the price range and province/city filters
  3. Retry the raw keyword without any --min-price/--max-price/--province/--city flags to confirm the keyword alone returns results

Example fix

// before
xianyu search '索尼 a7m4 95新 国行' --min-price 12000 --max-price 12050 --province 上海
// after
xianyu search 'sony a7m4' --min-price 10000 --max-price 15000
Defensive patterns

Strategy: fallback

Try / catch

try { return await xianyuSearch(args); } catch (e) { if (e instanceof EmptyResultError) { return await xianyuSearch({ ...args, query: broaden(args.query), 'min-price': undefined, 'max-price': undefined, province: undefined, city: undefined }); } throw e; }

Prevention

When it happens

Trigger: items array is present but empty: the keyword matched nothing, or price/province/city filters excluded every result.

Common situations: Very specific keywords, typos in the query, over-tight price ranges (e.g. --min-price 9000 --max-price 9001), filtering to a province/city with no matching listings.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/30721ba43303e2dd. Report an issue: GitHub.