jackwener/OpenCLI · error · AuthRequiredError

Xianyu search requires a logged-in browser session

Error message

Xianyu search requires a logged-in browser session

What it means

Xianyu (Goofish) search requires an authenticated browser session; the in-page script signals 'auth-required' when the mtop search call is rejected for lack of login, and the CLI converts this into an AuthRequiredError for www.goofish.com. The underlying mtop API refuses to serve search results to anonymous sessions.

Source

Thrown at clis/xianyu/search.js:225

    columns: ['item_id', 'rank', 'title', 'price', 'condition', 'brand', 'location', 'badge', 'want', 'url'],
    func: async (page, kwargs) => {
        const query = String(kwargs.query || '').trim();
        const limit = normalizeLimit(kwargs.limit);
        const minPrice = parsePriceArg(kwargs['min-price'], 'min-price');
        const maxPrice = parsePriceArg(kwargs['max-price'], 'max-price');
        if (minPrice != null && maxPrice != null && minPrice > maxPrice) {
            throw new ArgumentError('xianyu search min-price cannot be greater than max-price', `Received --min-price ${minPrice} and --max-price ${maxPrice}`);
        }
        const province = String(kwargs.province || '').trim();
        const city = String(kwargs.city || '').trim();
        const searchFilter = buildSearchFilter(minPrice, maxPrice);
        const extraFilterValue = buildExtraFilterValue(province, city);
        const fromFilter = Boolean(searchFilter) || extraFilterValue !== '{}';
        await page.goto(buildSearchUrl(query));
        await page.wait(2);
        const result = await page.evaluate(buildSearchEvaluate({ keyword: query, searchFilter, extraFilterValue, fromFilter, maxItems: limit }));
        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}`);
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to www.goofish.com in the library's managed browser session, then retry
  2. Re-run the library's login/auth flow command to refresh cookies
  3. Clear stale session state and re-authenticate if the site keeps rejecting the session
Defensive patterns

Strategy: try-catch

Validate before calling

// check login state before calling, e.g. via a session/profile check the library exposes
const loggedIn = await checkGoofishLogin();
if (!loggedIn) await runLoginFlow();

Try / catch

try { await xianyuSearch(args); } catch (e) { if (e instanceof AuthRequiredError) { await loginToGoofish(); return xianyuSearch(args); } throw e; }

Prevention

When it happens

Trigger: Running `xianyu search` while the managed browser session is logged out, the login cookie has expired, or the session was opened in an incognito/fresh profile.

Common situations: Cookies expiring after weeks of use, logging out of goofish.com manually, using a CI/headless environment with no logged-in profile, or a site-side session invalidation.

Related errors


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