jackwener/OpenCLI · error · EmptyResultError
coupang product
Error message
coupang product
What it means
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.
Source
Thrown at clis/coupang/product.js:234
const targetUrl = canonicalizeProductUrl(kwargs.url, productId);
const finalUrl = targetUrl || canonicalizeProductUrl('', productId);
await page.goto(finalUrl).catch((error) => {
throw new CommandExecutionError(`coupang product navigation failed: ${error?.message || error}`);
});
await page.wait(2).catch((error) => {
throw new CommandExecutionError(`coupang product wait failed: ${error?.message || error}`);
});
const result = await page.evaluate(buildProductDetailEvaluate(productId)).catch((error) => {
throw new CommandExecutionError(`coupang product extraction failed: ${error?.message || error}`);
});
const loginHints = result?.loginHints ?? {};
if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {
throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');
}
if (result?.reason === 'PRODUCT_MISMATCH') {
const actualProductId = normalizeProductId(result?.currentProductId || '');
const observed = actualProductId ? `got ${actualProductId}` : 'no product id observed';
throw new EmptyResultError('coupang product', `Product page redirected: expected ${productId}, ${observed} (item may be sold out or unavailable in your region)`);
}
if (!result?.ok || !result?.data) {
throw new EmptyResultError('coupang product', `No product data extracted from ${finalUrl}. The page may have failed to render or this product is restricted.`);
}
const actualProductId = normalizeProductId(result?.currentProductId || result.data.product_id || productId);
const data = result.data;
return [{
product_id: actualProductId,
title: data.title || null,
price: data.price ?? null,
original_price: data.original_price ?? null,
discount_rate: data.discount_rate ?? null,
rating: data.rating ?? null,
review_count: data.review_count ?? null,
seller: data.seller || null,
brand: data.brand || null,
rocket: data.rocket || null,
delivery_promise: data.delivery_promise || null,View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before opencli coupang product --url https://www.coupang.com/vp/products/OLD_ID // after opencli coupang product --url https://www.coupang.com/vp/products/CURRENT_ID
Defensive patterns
Strategy: fallback
Validate before calling
// verify the id is one you recently saw, not a stale cached one
if (isStale(productId, maxAgeHours)) throw new Error(`product id ${productId} may be outdated; refresh from search`); Type guard
function isProductMismatch(err) { return err?.code === 'EMPTY_RESULT' && /Product page redirected/.test(err.message); } Try / catch
try {
return await run('coupang product', { productId });
} catch (err) {
if (err?.code === 'EMPTY_RESULT' && /redirected/.test(err.message)) {
// item sold out / region-locked; fall back to searching by title
return await run('coupang search', { query: knownTitle });
}
throw err;
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- No prices returned for train_no=${trainNo} ${fromStation.nam
- No 12306 stations match "${keyword}"
- No trains found from ${fromStation.name} to ${toStation.name
- 1point3acres thread
- 1point3acres user
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/adfa052e19b31dde.
Report an issue: GitHub.