{"record":{"id":"d4309a543f7e9309","repo":"jackwener/OpenCLI","slug":"coupang-search-location-evaluation-failed-error","errorCode":null,"errorMessage":"coupang search location evaluation failed: ${error?.message || error}","messagePattern":"coupang search location evaluation failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coupang/search.js","lineNumber":443,"sourceCode":"        }\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        }\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);","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/search.js#L425-L461","documentation":"CommandExecutionError thrown when page.evaluate(buildCurrentLocationEvaluate()) fails while determining the current URL before navigating to a filtered page > 1. The current location read is needed to preserve the filtered URL when paginating.","triggerScenarios":"`coupang search <query> --filter \"...\" --page 2` where the location-evaluating evaluate rejects — page navigated during evaluate, cross-origin redirect, or browser closed.","commonSituations":"Filter application triggered an async redirect so evaluate runs mid-navigation; Coupang bot checks redirect to a login/challenge page breaking evaluate context.","solutions":["Retry the command; transient redirect races often resolve","Drop --filter so the paginate-via-location path is skipped","Use --page 1 to avoid the location-evaluation branch","Verify the session is not redirected to a login/captcha page"],"exampleFix":"// before\nconst locationInfo = await page.evaluate(buildCurrentLocationEvaluate());\n// after\nconst locationInfo = await page.evaluate(buildCurrentLocationEvaluate()).catch(() => null);\nconst filteredUrl = new URL(locationInfo?.href || url);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isHttpUrl(u) { try { const url = new URL(u); return url.protocol.startsWith('http'); } catch { return false; } }","tryCatchPattern":"try { await search({ filter, page: 2 }); } catch (e) { if (/location evaluation failed/.test(e.message)) { return search({ filter, page: 1 }); } throw e; }","preventionTips":["Avoid combining --filter with --page when redirects are likely","Retry transient navigation races","Watch for login/captcha redirects replacing the page"],"tags":["browser-automation","pagination","navigation"],"backgroundTag":"page-evaluate-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}