jackwener/OpenCLI · error · CommandExecutionError
Failed to export generated ChatGPT image assets
Error message
Failed to export generated ChatGPT image assets
What it means
clis/chatgpt/image.js throws this CommandExecutionError when `getChatGPTImageAssets(page, urls)` returns an empty array after the image-generation page was opened. It means the automation could not locate or export any downloadable image assets for the generated result (selector drift, lazy-loaded images, or a failed generation).
Source
Thrown at clis/chatgpt/image.js:151
if (!convUrl) {
convUrl = await currentChatGPTLink(page);
}
const urls = await waitForChatGPTImages(page, beforeUrls, timeout, convUrl);
const link = convUrl;
if (!urls.length) {
throw new EmptyResultError('chatgpt image', `No generated images were detected before timeout. Open ${link} and verify whether ChatGPT finished generating the image.`);
}
if (skipDownload) {
return [{ status: '🎨 generated', file: '📁 -', link: `🔗 ${link}` }];
}
// Export and save images
const assets = await getChatGPTImageAssets(page, urls);
if (!assets.length) {
throw new CommandExecutionError('Failed to export generated ChatGPT image assets', `Open ${link} and verify the generated images are visible, then retry.`);
}
const stamp = Date.now();
const results = [];
for (let index = 0; index < assets.length; index += 1) {
const asset = assets[index];
const base64 = asset.dataUrl.replace(/^data:[^;]+;base64,/, '');
const suffix = assets.length > 1 ? `_${index + 1}` : '';
const ext = extFromMime(asset.mimeType);
const filePath = nextAvailablePath(outputDir, `chatgpt_${stamp}${suffix}`, ext);
await saveBase64ToFile(base64, filePath);
results.push({ status: '✅ saved', file: `📁 ${displayPath(filePath)}`, link: `🔗 ${link}` });
}
return results;
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Open the result link manually and confirm images are visible, then retry the command.
- Retry after waiting a few seconds so lazy-loaded images finish rendering.
- Verify the ChatGPT session is logged in and images actually generated (check for a failure message in the conversation).
- Update the CLI so getChatGPTImageAssets selectors match the current ChatGPT DOM.
Example fix
// before
const assets = await getChatGPTImageAssets(page, urls);
if (!assets.length) throw new CommandExecutionError('Failed to export generated ChatGPT image assets', ...);
// after
await page.waitForSelector('img[src*="oaiusercontent"], img[data-generated]', { timeout: 15000 });
const assets = await getChatGPTImageAssets(page, urls);
if (!assets.length) throw new CommandExecutionError('Failed to export generated ChatGPT image assets', ...); Defensive patterns
Strategy: retry
Validate before calling
// Retry wrapper
async function exportWithRetry(page, urls, link, attempts = 3) {
for (let i = 0; i < attempts; i++) {
const assets = await getChatGPTImageAssets(page, urls);
if (assets.length) return assets;
await page.waitForTimeout(3000 * (i + 1));
}
throw new Error(`No assets exported; open ${link} to verify images are visible`);
} Type guard
function hasAssets(a) { return Array.isArray(a) && a.length > 0; } Try / catch
try {
const assets = await getChatGPTImageAssets(page, urls);
if (!assets.length) throw new Error('no assets');
} catch (err) {
console.error(`Open ${link} and verify images are visible, then retry.`);
} Prevention
- Wait for image selectors to appear before scraping (waitForSelector).
- Retry asset collection with backoff for lazy-loaded galleries.
- Confirm generation succeeded before attempting export.
- Keep scraping selectors updated against the current ChatGPT DOM.
When it happens
Trigger: Running a `chatgpt image` command where the browser automation opens the result link, calls getChatGPTImageAssets, and the assets array comes back length 0.
Common situations: ChatGPT UI markup changed so image selectors no longer match; the generation actually failed server-side; images not yet rendered when scraped; slow network/proxy causing the gallery to never hydrate; user not logged in so a fallback page loaded.
Related errors
- chatgpt project-list
- chatgpt read
- discord-app channels
- linkedin timeline
- 未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/907ba9ea654780e5.
Report an issue: GitHub.