{"record":{"id":"adfa052e19b31dde","repo":"jackwener/OpenCLI","slug":"coupang-product","errorCode":null,"errorMessage":"coupang product","messagePattern":"coupang product","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/coupang/product.js","lineNumber":234,"sourceCode":"        const targetUrl = canonicalizeProductUrl(kwargs.url, productId);\n        const finalUrl = targetUrl || canonicalizeProductUrl('', productId);\n        await page.goto(finalUrl).catch((error) => {\n            throw new CommandExecutionError(`coupang product navigation failed: ${error?.message || error}`);\n        });\n        await page.wait(2).catch((error) => {\n            throw new CommandExecutionError(`coupang product wait failed: ${error?.message || error}`);\n        });\n        const result = await page.evaluate(buildProductDetailEvaluate(productId)).catch((error) => {\n            throw new CommandExecutionError(`coupang product extraction failed: ${error?.message || error}`);\n        });\n        const loginHints = result?.loginHints ?? {};\n        if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {\n            throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');\n        }\n        if (result?.reason === 'PRODUCT_MISMATCH') {\n            const actualProductId = normalizeProductId(result?.currentProductId || '');\n            const observed = actualProductId ? `got ${actualProductId}` : 'no product id observed';\n            throw new EmptyResultError('coupang product', `Product page redirected: expected ${productId}, ${observed} (item may be sold out or unavailable in your region)`);\n        }\n        if (!result?.ok || !result?.data) {\n            throw new EmptyResultError('coupang product', `No product data extracted from ${finalUrl}. The page may have failed to render or this product is restricted.`);\n        }\n        const actualProductId = normalizeProductId(result?.currentProductId || result.data.product_id || productId);\n        const data = result.data;\n        return [{\n                product_id: actualProductId,\n                title: data.title || null,\n                price: data.price ?? null,\n                original_price: data.original_price ?? null,\n                discount_rate: data.discount_rate ?? null,\n                rating: data.rating ?? null,\n                review_count: data.review_count ?? null,\n                seller: data.seller || null,\n                brand: data.brand || null,\n                rocket: data.rocket || null,\n                delivery_promise: data.delivery_promise || null,","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/product.js#L216-L252","documentation":"EmptyResultError (exit code 66, EX_NOINPUT) raised when the product page redirected to a different product than requested (result.reason === 'PRODUCT_MISMATCH'). The message reports the expected vs observed product id, noting the item may be sold out or region-restricted.","triggerScenarios":"`opencli coupang product --url/--product-id <id>` where canonicalizeProductUrl landed on a page whose currentProductId differs from the requested productId — Coupang redirected to a replacement item, a category page, or a sold-out notice.","commonSituations":"Product discontinued and Coupang redirects to a similar item; item sold out and Coupang redirects; region restriction serving a different storefront page; stale/dead product-id scraped from an old list; typo'd product id resolving to another item.","solutions":["Compare the observed product id in the message with the requested one to confirm the redirect.","Re-check the product URL in a browser — if Coupang redirects there too, the item is gone/region-locked.","Use a fresh product id/URL (e.g. from a current search result) instead of a cached one.","Retry from a different region/proxy if regional availability is the cause."],"exampleFix":"// before\nopencli coupang product --url https://www.coupang.com/vp/products/OLD_ID\n// after\nopencli coupang product --url https://www.coupang.com/vp/products/CURRENT_ID","handlingStrategy":"fallback","validationCode":"// verify the id is one you recently saw, not a stale cached one\nif (isStale(productId, maxAgeHours)) throw new Error(`product id ${productId} may be outdated; refresh from search`);","typeGuard":"function isProductMismatch(err) { return err?.code === 'EMPTY_RESULT' && /Product page redirected/.test(err.message); }","tryCatchPattern":"try {\n  return await run('coupang product', { productId });\n} catch (err) {\n  if (err?.code === 'EMPTY_RESULT' && /redirected/.test(err.message)) {\n    // item sold out / region-locked; fall back to searching by title\n    return await run('coupang search', { query: knownTitle });\n  }\n  throw err;\n}","preventionTips":["Refresh product ids from current search/list results instead of long-lived caches.","Check the URL in a browser when a redirect is reported — it confirms the item's status.","Handle exit code 66 (EMPTY_RESULT) as 'no data', not a crash, in scripts.","For region-sensitive catalogs, test availability from your actual region."],"tags":["empty-result","redirect","product","coupang"],"backgroundTag":"empty-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}