{"record":{"id":"88c75638ac800d4a","repo":"jackwener/OpenCLI","slug":"coupang-search-extraction-failed-error-message","errorCode":null,"errorMessage":"coupang search extraction failed: ${error?.message || error}","messagePattern":"coupang search extraction failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coupang/search.js","lineNumber":456,"sourceCode":"            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        }\n        await page.autoScroll({ times: filter ? 3 : 2, delayMs: 1500 }).catch((error) => {\n            throw new CommandExecutionError(`coupang search scroll failed: ${error?.message || error}`);\n        });\n        const raw = await page.evaluate(buildSearchEvaluate(query, limit, pageNumber)).catch((error) => {\n            throw new CommandExecutionError(`coupang search extraction failed: ${error?.message || error}`);\n        });\n        const loginHints = raw?.loginHints ?? {};\n        const items = Array.isArray(raw?.items) ? raw.items : [];\n        const domItems = Array.isArray(raw?.domItems) ? raw.domItems : [];\n        const normalizedBase = sanitizeSearchItems(items.map((item, index) => normalizeSearchItem(item, index)), limit);\n        const normalizedDom = sanitizeSearchItems(domItems.map((item, index) => normalizeSearchItem(item, index)), Math.max(limit * 6, 60));\n        const normalized = filter\n            ? sanitizeSearchItems(normalizedDom, limit)\n            : mergeSearchItems(normalizedBase, normalizedDom, limit);\n        if (!normalized.length) {\n            if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {\n                throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');\n            }\n            throw new EmptyResultError('coupang search', `No products matched \"${query}\". Try a more specific keyword or remove --filter.`);\n        }\n        return normalized;\n    },\n});","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/search.js#L438-L474","documentation":"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.","triggerScenarios":"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.","commonSituations":"Coupang frontend deploy changing result markup/JSON embedding; bot-detection page replacing results; session/browser crash during extraction.","solutions":["Retry; if consistently failing, Coupang markup likely changed","Check whether the page shows a login or bot-check interstitial first","Update the CLI to the latest version with updated extraction selectors","Run with a logged-in Chrome profile if results are gated"],"exampleFix":"// before\nconst raw = await page.evaluate(buildSearchEvaluate(query, limit, pageNumber));\n// after\nconst raw = await page.evaluate(buildSearchEvaluate(query, limit, pageNumber)).catch(e => {\n  console.error('extraction failed:', e.message);\n  throw e;\n});","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const items = await coupangSearch(query); } catch (e) { if (/extraction failed/.test(e.message)) { await sleep(3000); return coupangSearch(query); } throw e; }","preventionTips":["Keep the CLI updated against Coupang DOM changes","Ensure the page is fully loaded and not a bot-check page","Log in to Coupang if results are gated"],"tags":["browser-automation","dom","scraping"],"backgroundTag":"page-evaluate-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}