jackwener/OpenCLI · error · AuthRequiredError

item.jd.com

Error message

item.jd.com

What it means

The jd item command throws AuthRequiredError('item.jd.com', data.error) when the item scrape returns an error AND the page state looks blocked (pageState.looksBlocked). JD served an anti-bot / verification / login interstitial instead of the product page, so the scrape result is untrustworthy and the library classifies it as an access/auth problem.

Source

Thrown at clis/jd/item.js:689

        const srcs = allImgs.map(img => img.src).filter(Boolean);

        const mainImages = extractMainImages(maxImg);
        const detailImages = await extractDetailImagesFromPage(maxImg, ${JSON.stringify(sku)});
        const specs = extractSpecs();

        const result = { title, price, shop, specs, mainImages, detailImages, totalImages: new Set(srcs).size, pageState };
        if (!pageState.isProductPage) {
          result.error = pageState.looksBlocked
            ? 'JD page is blocked by login/security verification'
            : 'JD product page was not loaded';
          result.pageState = pageState;
        }
        return result;
      })()
    `);
        if (data?.error) {
            if (data?.pageState?.looksBlocked) {
                throw new AuthRequiredError('item.jd.com', data.error);
            }
            throw new CommandExecutionError(data.error);
        }
        if (maxImages > 0 && data?.pageState?.isProductPage && (!Array.isArray(data.detailImages) || data.detailImages.length === 0)) {
            throw new CommandExecutionError('JD item detail images were not found', 'The product page loaded, but no detail images were detected from DOM, scripts, frames, page data, or WareGraphic fallback.');
        }
        return [data];
    },
});
export const __test__ = {
    normalizePositiveInt,
    normalizeJdSkuInput,
    normalizeJdImageUrl,
    normalizeJdImageSize,
    isJdMainImage,
    collectImageUrlsFrom,
    collectImageUrlsFromText,
    collectImageUrlsFromFramesAndScripts,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Slow down request rate / add delays between item fetches to avoid risk control
  2. Open item.jd.com in the connected browser and complete any captcha/verification manually
  3. Log in to JD — logged-in sessions are less aggressively blocked
  4. Retry later or from a different network/residential IP if the block persists

Example fix

// before
const item = await jdItem(sku);
// after
try {
  const item = await jdItem(sku);
} catch (e) {
  if (e.code === 'AUTH_REQUIRED') {
    await openBrowserAndSolveChallenge('https://item.jd.com');
    const item = await jdItem(sku);
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// throttle: never fetch items back-to-back
await sleep(1500 + Math.random() * 1500);
const item = await jdItem(sku);

Type guard

function isBlockedError(e) {
  return e?.code === 'AUTH_REQUIRED' && e?.domain === 'item.jd.com';
}

Try / catch

try {
  return await jdItem(sku, { maxImages });
} catch (e) {
  if (isBlockedError(e)) {
    await backoff(delay *= 2); // complete challenge in browser, then retry
    return jdItem(sku, { maxImages });
  }
  throw e;
}

Prevention

When it happens

Trigger: Fetching `jd item <sku>` when JD blocks the headless/browser request — risk-control interstitial, verification page, or login wall — detected via the pageState.looksBlocked flag computed in the evaluate script.

Common situations: Aggressive scraping of many SKUs triggering JD risk control; datacenter IP or headless profile flagged; JD serving captcha walls during high traffic; cookies absent so the item page redirects to verification.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/42f9e8b3c5b857b3. Report an issue: GitHub.