{"record":{"id":"a38289fa508ec554","repo":"jackwener/OpenCLI","slug":"instagram-image-preview-did-not-appear-after-uploa","errorCode":null,"errorMessage":"Instagram image preview did not appear after upload","messagePattern":"Instagram image preview did not appear after upload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/post.js","lineNumber":782,"sourceCode":"    })()\n  `);\n    return !!result?.ok;\n}\nasync function waitForPreview(page, maxWaitSeconds = 12) {\n    const attempts = Math.max(1, Math.ceil(maxWaitSeconds));\n    for (let attempt = 0; attempt < attempts; attempt++) {\n        const state = await inspectUploadStage(page);\n        if (state.state === 'preview')\n            return;\n        if (state.state === 'failed') {\n            await page.screenshot({ path: '/tmp/instagram_post_preview_debug.png' });\n            throw makeUploadFailure('Inspect /tmp/instagram_post_preview_debug.png. ' + (state.detail || ''));\n        }\n        if (attempt < attempts - 1)\n            await page.wait({ time: 1 });\n    }\n    await page.screenshot({ path: '/tmp/instagram_post_preview_debug.png' });\n    throw new CommandExecutionError('Instagram image preview did not appear after upload', 'The selected file input may not match the active composer; inspect /tmp/instagram_post_preview_debug.png');\n}\nasync function waitForPreviewMaybe(page, maxWaitSeconds = 4) {\n    const attempts = Math.max(1, Math.ceil(maxWaitSeconds * 2));\n    for (let attempt = 0; attempt < attempts; attempt++) {\n        const state = await inspectUploadStage(page);\n        if (state.state !== 'pending')\n            return state;\n        if (attempt < attempts - 1)\n            await page.wait({ time: 0.5 });\n    }\n    return { state: 'pending' };\n}\nexport function buildClickActionJs(labels, scope = 'any') {\n    return `\n    ((labels, scope) => {\n      const isVisible = (el) => {\n        if (!(el instanceof HTMLElement)) return false;\n        const style = window.getComputedStyle(el);","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/post.js#L764-L800","documentation":"waitForPreview polls the composer after upload to confirm Instagram shows a preview thumbnail of the uploaded media. If after all attempts the preview never appears, it saves /tmp/instagram_post_preview_debug.png and throws this error. It signals the upload never took effect from Instagram's perspective.","triggerScenarios":"executeUiInstagramPost -> waitForPreview exhausts its polling attempts with inspectUploadStage never leaving 'pending'/absent state; also thrown via makeUploadFailure path when inspectUploadStage reports a failed upload stage with detail.","commonSituations":"Wrong file input selected (selector matches a hidden/unused input), Instagram silently rejecting the file (format, size, aspect ratio), slow network upload not finished within the wait window, or a session/2FA interstitial blocking the composer.","solutions":["Inspect /tmp/instagram_post_preview_debug.png to see what the composer actually shows","Re-run and allow more wait time for large files or slow connections","Verify the media file meets Instagram's format/size limits before retrying","Re-resolve upload selectors in case the first selector targeted a non-composer input","Log in again if a session interstitial appears in the debug screenshot"],"exampleFix":"// before\nawait postImage(page, hugeFile); // 8MB, slow link, preview never appears\n// after\nconst stat = fs.statSync(hugeFile);\nif (stat.size > 4 * 1024 * 1024) await compressImage(hugeFile);\nawait postImage(page, hugeFile);","handlingStrategy":"retry","validationCode":"const stat = fs.statSync(filePath);\nif (!/^\\.(jpe?g|png)$/i.test(path.extname(filePath)) || stat.size > 8 * 1024 * 1024) {\n  throw new Error('Media not Instagram-compatible: ' + filePath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await postImage(page, file);\n} catch (e) {\n  if (String(e.message).includes('preview did not appear')) {\n    // debug shot is at /tmp/instagram_post_preview_debug.png\n    await page.wait({ time: 5 });\n    return postImage(page, file); // one slower retry\n  }\n  throw e;\n}","preventionTips":["Pre-validate media format and size against Instagram limits","Allow generous waits for large files or slow links","Check the debug screenshot after each failure before changing code"],"tags":["instagram","upload-timeout","ui-automation"],"backgroundTag":"preview-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}