jackwener/OpenCLI · error · EmptyResultError

coupang search

Error message

coupang search

What it means

CommandExecutionError thrown when the in-page evaluation that applies a Coupang search filter (buildApplyFilterEvaluate) throws inside page.evaluate. The wrapper rethrows with the inner error message so the CLI surfaces a 'coupang search filter evaluation failed: ...' message instead of a raw browser exception.

Source

Thrown at clis/coupang/search.js:436

            throw new ArgumentError('query cannot be empty');
        }
        const pageNumber = parsePageArg(kwargs.page, 1);
        const limit = parseLimitArg(kwargs.limit, 20, 50);
        const filter = String(kwargs.filter || '').trim().toLowerCase();
        if (filter && filter !== 'rocket') {
            throw new ArgumentError(`Unsupported --filter "${filter}" (supported: rocket)`);
        }
        const initialPage = filter ? 1 : pageNumber;
        const url = `https://www.coupang.com/np/search?q=${encodeURIComponent(query)}&channel=user&page=${initialPage}`;
        await page.goto(url).catch((error) => {
            throw new CommandExecutionError(`coupang search navigation failed: ${error?.message || error}`);
        });
        if (filter) {
            const filterResult = await page.evaluate(buildApplyFilterEvaluate(filter)).catch((error) => {
                throw new CommandExecutionError(`coupang search filter evaluation failed: ${error?.message || error}`);
            });
            if (!filterResult?.ok) {
                throw new EmptyResultError('coupang search', `Filter "${filter}" was not available on the current page; try without --filter or wait for Coupang to render the filter bar.`);
            }
            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}`);
        });

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command without --filter to confirm the failure is filter-specific
  2. Wait for the search results/filter bar to fully render before retrying
  3. Update the CLI to a version matching current Coupang markup
  4. Check that Chrome/the browser session is alive and not crashed

Example fix

// before
await page.evaluate(buildApplyFilterEvaluate(filter));
// after
await page.wait(2);
await page.evaluate(buildApplyFilterEvaluate(filter)).catch(e => {
  console.warn('filter apply failed, continuing without filter', e);
});
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeof filter !== 'string' || !filter.trim()) throw new Error('--filter must be a non-empty string');

Type guard

function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; }

Try / catch

try { await coupangSearch({ query, filter }); } catch (e) { if (e instanceof CommandExecutionError && /filter evaluation failed/.test(e.message)) { /* retry without --filter */ } else throw e; }

Prevention

When it happens

Trigger: Running `coupang search <query> --filter "..."` when the evaluate that applies the filter throws — e.g. the filter bar DOM changed, the page navigated mid-evaluate, or the page evaluate API itself rejected.

Common situations: Coupang markup changed after an A/B update; filter applied too early before the filter bar rendered; browser tab crashed or page closed mid-command; Chrome extension injecting scripts that break evaluate.

Related errors


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