{"record":{"id":"08f01d58092f9191","repo":"jackwener/OpenCLI","slug":"data-error","errorCode":null,"errorMessage":"data.error","messagePattern":"data\\.error","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/jd/item.js","lineNumber":691,"sourceCode":"        const mainImages = extractMainImages(maxImg);\n        const detailImages = await extractDetailImagesFromPage(maxImg, ${JSON.stringify(sku)});\n        const specs = extractSpecs();\n\n        const result = { title, price, shop, specs, mainImages, detailImages, totalImages: new Set(srcs).size, pageState };\n        if (!pageState.isProductPage) {\n          result.error = pageState.looksBlocked\n            ? 'JD page is blocked by login/security verification'\n            : 'JD product page was not loaded';\n          result.pageState = pageState;\n        }\n        return result;\n      })()\n    `);\n        if (data?.error) {\n            if (data?.pageState?.looksBlocked) {\n                throw new AuthRequiredError('item.jd.com', data.error);\n            }\n            throw new CommandExecutionError(data.error);\n        }\n        if (maxImages > 0 && data?.pageState?.isProductPage && (!Array.isArray(data.detailImages) || data.detailImages.length === 0)) {\n            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.');\n        }\n        return [data];\n    },\n});\nexport const __test__ = {\n    normalizePositiveInt,\n    normalizeJdSkuInput,\n    normalizeJdImageUrl,\n    normalizeJdImageSize,\n    isJdMainImage,\n    collectImageUrlsFrom,\n    collectImageUrlsFromText,\n    collectImageUrlsFromFramesAndScripts,\n    collectImageUrlsFromPayload,\n    collectImageUrlsFromPageDataObjects,","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jd/item.js#L673-L709","documentation":"The jd item command throws CommandExecutionError(data.error) when the scrape returns an error without the page looking blocked — i.e. a genuine scrape failure relayed from the in-page script (page didn't load, SKU invalid, DOM structure unexpected). Unlike error 2086, pageState.looksBlocked is false, so it's not classified as auth/block.","triggerScenarios":"`jd item <sku>` where the evaluate script sets data.error because the product page failed to load, the SKU doesn't exist or was removed, or expected product markup was missing while the page otherwise looks normal.","commonSituations":"Invalid/deleted JD SKU passed by the caller; network hiccup loading item.jd.com; JD page redesign breaking selectors without a block page; page timed out mid-load.","solutions":["Verify the SKU/URL is a valid, live JD product","Retry the command — transient load failures are common","Open the item URL in a normal browser to confirm it renders","Update opencli if JD changed its page structure"],"exampleFix":"// before\nconst item = await jdItem(maybeBadSku);\n// after\nif (!/^\\d+$/.test(sku)) throw new Error('invalid JD sku');\ntry {\n  const item = await jdItem(sku);\n} catch (e) {\n  if (e.code === 'COMMAND_EXEC') { /* handle scrape failure */ }\n}","handlingStrategy":"validation","validationCode":"if (!/^\\d{1,12}$/.test(String(sku))) {\n  throw new Error(`Invalid JD SKU: ${sku}`);\n}\n// optionally pre-check the item exists before scraping","typeGuard":"function isScrapeError(e) {\n  return e?.code === 'COMMAND_EXEC' && e?.message && !/detail images/.test(e.message);\n}","tryCatchPattern":"try {\n  return await jdItem(sku);\n} catch (e) {\n  if (isScrapeError(e)) {\n    console.error(`JD item scrape failed for ${sku}: ${e.message}`);\n    return null; // skip bad SKUs in batch jobs\n  }\n  throw e;\n}","preventionTips":["Validate SKU format before calling jd item","Check SKUs are live products (removed items fail to scrape)","Retry transient load failures once before giving up","Keep opencli updated for JD markup changes"],"tags":["jd","scrape","command-execution","invalid-item"],"backgroundTag":"page-scrape-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}