{"record":{"id":"3ae872f2a4ceb8ca","repo":"jackwener/OpenCLI","slug":"coupang-search-filter-evaluation-failed-error","errorCode":null,"errorMessage":"coupang search filter evaluation failed: ${error?.message || error}","messagePattern":"coupang search filter evaluation failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coupang/search.js","lineNumber":433,"sourceCode":"    func: async (page, kwargs) => {\n        const query = String(kwargs.query || '').trim();\n        if (!query) {\n            throw new ArgumentError('query cannot be empty');\n        }\n        const pageNumber = parsePageArg(kwargs.page, 1);\n        const limit = parseLimitArg(kwargs.limit, 20, 50);\n        const filter = String(kwargs.filter || '').trim().toLowerCase();\n        if (filter && filter !== 'rocket') {\n            throw new ArgumentError(`Unsupported --filter \"${filter}\" (supported: rocket)`);\n        }\n        const initialPage = filter ? 1 : pageNumber;\n        const url = `https://www.coupang.com/np/search?q=${encodeURIComponent(query)}&channel=user&page=${initialPage}`;\n        await page.goto(url).catch((error) => {\n            throw new CommandExecutionError(`coupang search navigation failed: ${error?.message || error}`);\n        });\n        if (filter) {\n            const filterResult = await page.evaluate(buildApplyFilterEvaluate(filter)).catch((error) => {\n                throw new CommandExecutionError(`coupang search filter evaluation failed: ${error?.message || error}`);\n            });\n            if (!filterResult?.ok) {\n                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.`);\n            }\n            await page.wait(3).catch((error) => {\n                throw new CommandExecutionError(`coupang search wait failed: ${error?.message || error}`);\n            });\n            if (pageNumber > 1) {\n                const locationInfo = await page.evaluate(buildCurrentLocationEvaluate()).catch((error) => {\n                    throw new CommandExecutionError(`coupang search location evaluation failed: ${error?.message || error}`);\n                });\n                const filteredUrl = new URL(locationInfo?.href || url);\n                filteredUrl.searchParams.set('page', String(pageNumber));\n                await page.goto(filteredUrl.toString()).catch((error) => {\n                    throw new CommandExecutionError(`coupang search filtered navigation failed: ${error?.message || error}`);\n                });\n            }\n        }","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/search.js#L415-L451","documentation":"Wraps a failure of page.evaluate(buildApplyFilterEvaluate(filter)) — the in-page script that clicks/opens the requested search filter (e.g. rocket) on the Coupang search results page. Failures of the evaluation itself are rethrown as a CommandExecutionError with this message (distinct from the EmptyResultError thrown when the filter evaluates ok but reports not-available).","triggerScenarios":"`opencli coupang search <query> --filter rocket` where the filter-apply evaluate throws: filter bar not yet rendered when the script runs, page closed/navigated during evaluate, script error from a Coupang DOM change, or browser command timeout.","commonSituations":"Slow Coupang render so the filter bar doesn't exist when evaluate executes; bot-detection page without the filter UI; Coupang renamed filter elements breaking the script; extension dropped mid-command.","solutions":["Retry — a slow render usually resolves on a second run.","Load the search page in a normal Chrome window and confirm the filter bar renders; complete any captcha first.","Increase --timeout if the evaluate is timing out.","If it persists after Coupang UI changes, update the CLI to a version with fixed filter selectors.","Run without --filter and filter results client-side as a workaround."],"exampleFix":"// before\nconst filterResult = await page.evaluate(buildApplyFilterEvaluate(filter));\n// after\nawait page.goto(url);\nawait page.wait(3); // let the filter bar render\nconst filterResult = await page.evaluate(buildApplyFilterEvaluate(filter)).catch((error) => {\n    throw new CommandExecutionError(`coupang search filter evaluation failed: ${error?.message || error}`);\n});","handlingStrategy":"fallback","validationCode":"// if a filter is requested, be ready to run without it\nconst useFilter = Boolean(filter) && SUPPORTED_FILTERS.includes(String(filter).trim().toLowerCase());\nif (filter && !useFilter) console.warn(`filter \"${filter}\" unsupported/fragile; falling back to unfiltered search`);","typeGuard":"function isFilterEvalFailure(err) { return err?.code === 'COMMAND_EXEC' && /filter evaluation failed/.test(err.message); }","tryCatchPattern":"try {\n  return await run('coupang search', { query, filter });\n} catch (err) {\n  if (isFilterEvalFailure(err)) {\n    return await run('coupang search', { query }); // fallback: unfiltered results\n  }\n  throw err;\n}","preventionTips":["Let the search results page fully render before applying filters (avoid slow-network runs).","Complete captchas/logins so the filter bar is actually present.","Prefer running without --filter and filtering results client-side when reliability matters.","Update the CLI when Coupang changes its filter UI."],"tags":["extraction","filter","dom","coupang"],"backgroundTag":"page-evaluate-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}