{"record":{"id":"feb5a5c1620e90aa","repo":"jackwener/OpenCLI","slug":"failed-to-fetch-generated-qianwen-image-i-1","errorCode":null,"errorMessage":"Failed to fetch generated Qianwen image ${i + 1}: status=${asset?.status || '?'}","messagePattern":"Failed to fetch generated Qianwen image (.+?): status=(.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qwen/image.js","lineNumber":166,"sourceCode":"        const waitResult = await waitForImageUrls(page, targetId, timeout);\n        const link = await page.evaluate('window.location.href').catch(() => 'https://www.qianwen.com/');\n        if (waitResult.status === 'auth_required') throw authRequired();\n        if (waitResult.status === 'timeout') {\n            throw new TimeoutError('qianwen image', timeout, 'No generated images observed before timeout.');\n        }\n\n        const urls = waitResult.urls;\n        if (skipDownload) {\n            return [{ Status: '🎨 generated', File: null, Link: link }];\n        }\n\n        const stamp = Date.now();\n        const results = [];\n        for (let i = 0; i < urls.length; i += 1) {\n            const url = urls[i];\n            const asset = await fetchImageAsset(page, url);\n            if (!asset?.ok) {\n                throw new CommandExecutionError(`Failed to fetch generated Qianwen image ${i + 1}: status=${asset?.status || '?'}`);\n            }\n            const suffix = urls.length > 1 ? `_${i + 1}` : '';\n            const ext = extFromMime(asset.mime);\n            const filePath = path.join(outputDir, `qianwen_${stamp}${suffix}${ext}`);\n            await saveBase64ToFile(asset.base64, filePath);\n            results.push({ Status: '✅ saved', File: displayPath(filePath), Link: link });\n        }\n        if (!results.length) {\n            throw new EmptyResultError('qwen image', 'No generated images were available to download.');\n        }\n        return results;\n    },\n});\n","sourceCodeStart":148,"sourceCodeEnd":180,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/image.js#L148-L180","documentation":"After URLs are collected, clis/qwen/image.js calls fetchImageAsset(page, url) for each one; if the asset is not ok it throws CommandExecutionError('Failed to fetch generated Qianwen image N: status=...') including the HTTP status or '?' when unknown. The generated image exists but downloading it failed.","triggerScenarios":"The image CDN URL expired (signed URLs with short TTL) by download time; fetch returned 403/404 from the page context; the URL points to a domain blocked by the browser session's cookies/headers; asset?.status is undefined giving '?' on a network-level failure.","commonSituations":"Waiting too long between generation and download so signed links expire; proxy/firewall stripping the CDN request; multiple images where one of several URLs 404s; rate limiting on the CDN after several downloads.","solutions":["Re-run the command so fresh URLs are generated and downloaded immediately (avoids expired signed links)","Note the status in the message: 403/401 -> re-login to qianwen.com; 404 -> URL expired, regenerate","Reduce delay between generation and download; avoid caching URLs across runs","If '?' and reproducible, check network/proxy access to the image CDN host from the automation browser"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await downloadGeneratedImages(urls);\n} catch (e) {\n  const m = e.message.match(/status=(\\d+|\\?)/);\n  const status = m && m[1];\n  if (status === '401' || status === '403') {\n    await relogin(page);                   // refresh cookies, then regenerate\n  } else if (status === '404' || status === '?') {\n    await regenerateAndDownload(prompt);   // signed URL expired; get fresh URLs\n  } else throw e;\n}","preventionTips":["Download immediately after generation — CDN URLs are signed and short-lived","Never cache image URLs across runs","Check the status code in the error message to choose between re-login and regeneration","Verify proxy/firewall allows the image CDN host from the automation browser"],"tags":["network","http","image-download"],"backgroundTag":"image-download-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}