jackwener/OpenCLI · error · CommandExecutionError

coupang search extraction failed: ${error?.message || error}

Error message

coupang search extraction failed: ${error?.message || error}

What it means

CommandExecutionError thrown when the main search-result extraction evaluate (buildSearchEvaluate) fails inside page.evaluate. This is the core data-pull step; without it no items can be returned.

Source

Thrown at clis/coupang/search.js:456

            await page.wait(3).catch((error) => {
                throw new CommandExecutionError(`coupang search wait failed: ${error?.message || error}`);
            });
            if (pageNumber > 1) {
                const locationInfo = await page.evaluate(buildCurrentLocationEvaluate()).catch((error) => {
                    throw new CommandExecutionError(`coupang search location evaluation failed: ${error?.message || error}`);
                });
                const filteredUrl = new URL(locationInfo?.href || url);
                filteredUrl.searchParams.set('page', String(pageNumber));
                await page.goto(filteredUrl.toString()).catch((error) => {
                    throw new CommandExecutionError(`coupang search filtered navigation failed: ${error?.message || error}`);
                });
            }
        }
        await page.autoScroll({ times: filter ? 3 : 2, delayMs: 1500 }).catch((error) => {
            throw new CommandExecutionError(`coupang search scroll failed: ${error?.message || error}`);
        });
        const raw = await page.evaluate(buildSearchEvaluate(query, limit, pageNumber)).catch((error) => {
            throw new CommandExecutionError(`coupang search extraction failed: ${error?.message || error}`);
        });
        const loginHints = raw?.loginHints ?? {};
        const items = Array.isArray(raw?.items) ? raw.items : [];
        const domItems = Array.isArray(raw?.domItems) ? raw.domItems : [];
        const normalizedBase = sanitizeSearchItems(items.map((item, index) => normalizeSearchItem(item, index)), limit);
        const normalizedDom = sanitizeSearchItems(domItems.map((item, index) => normalizeSearchItem(item, index)), Math.max(limit * 6, 60));
        const normalized = filter
            ? sanitizeSearchItems(normalizedDom, limit)
            : mergeSearchItems(normalizedBase, normalizedDom, limit);
        if (!normalized.length) {
            if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {
                throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');
            }
            throw new EmptyResultError('coupang search', `No products matched "${query}". Try a more specific keyword or remove --filter.`);
        }
        return normalized;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry; if consistently failing, Coupang markup likely changed
  2. Check whether the page shows a login or bot-check interstitial first
  3. Update the CLI to the latest version with updated extraction selectors
  4. Run with a logged-in Chrome profile if results are gated

Example fix

// before
const raw = await page.evaluate(buildSearchEvaluate(query, limit, pageNumber));
// after
const raw = await page.evaluate(buildSearchEvaluate(query, limit, pageNumber)).catch(e => {
  console.error('extraction failed:', e.message);
  throw e;
});
Defensive patterns

Strategy: retry

Try / catch

try { const items = await coupangSearch(query); } catch (e) { if (/extraction failed/.test(e.message)) { await sleep(3000); return coupangSearch(query); } throw e; }

Prevention

When it happens

Trigger: Any `coupang search <query>` run where the extraction script throws in-page — Coupang DOM restructured, page navigated mid-evaluate, evaluate context destroyed by client-side redirect.

Common situations: Coupang frontend deploy changing result markup/JSON embedding; bot-detection page replacing results; session/browser crash during extraction.

Related errors


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