{"record":{"id":"14a35409ee1e85b5","repo":"jackwener/OpenCLI","slug":"failed-to-open-instagram-reel-composer","errorCode":null,"errorMessage":"Failed to open Instagram reel composer","messagePattern":"Failed to open Instagram reel composer","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/reel.js","lineNumber":73,"sourceCode":"    const baseName = path.basename(filePath);\n    if (/^[a-zA-Z0-9._-]+$/.test(baseName)) {\n        return { originalPath: filePath, uploadPath: filePath };\n    }\n    const uploadPath = buildSafeTempVideoPath(filePath);\n    fs.copyFileSync(filePath, uploadPath);\n    return {\n        originalPath: filePath,\n        uploadPath,\n        cleanupPath: uploadPath,\n    };\n}\nasync function ensureComposerOpen(page) {\n    const result = await page.evaluate(buildEnsureComposerOpenJs());\n    if (!result?.ok) {\n        if (result?.reason === 'auth') {\n            throw new AuthRequiredError('www.instagram.com', 'Instagram login required before posting a reel');\n        }\n        throw new CommandExecutionError('Failed to open Instagram reel composer');\n    }\n    for (let attempt = 0; attempt < 12; attempt += 1) {\n        const ready = await page.evaluate(`\n      (() => {\n        const isVisible = (el) => {\n          if (!(el instanceof HTMLElement)) return false;\n          const style = window.getComputedStyle(el);\n          const rect = el.getBoundingClientRect();\n          return style.display !== 'none'\n            && style.visibility !== 'hidden'\n            && rect.width > 0\n            && rect.height > 0;\n        };\n        const inputs = Array.from(document.querySelectorAll('input[type=\"file\"]'))\n          .filter((el) => el instanceof HTMLInputElement)\n          .filter((el) => {\n            const dialog = el.closest('[role=\"dialog\"]');\n            return dialog instanceof HTMLElement && isVisible(dialog);","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/reel.js#L55-L91","documentation":"If ensureComposerOpen's in-page script returns a non-ok result whose reason is not 'auth', the library throws CommandExecutionError 'Failed to open Instagram reel composer'. It means the composer could not be opened for a non-login reason — page structure unexpected, navigation failed, or Instagram served an interstitial.","triggerScenarios":"page.evaluate returning ok:false with reasons like DOM mismatch (Instagram markup changed), page on a wrong URL/error page, rate-limit or 'try again later' interstitial, or the evaluate itself failing softly.","commonSituations":"Instagram UI/A/B test changed composer markup, account flagged with restrictions blocking posting, network hiccup during navigation, or landing on instagram.com variant pages.","solutions":["Retry after confirming the page is on instagram.com and fully loaded.","Log in and check the account can post manually in the same browser session (look for restrictions/blocks).","Update the CLI/library if Instagram's DOM changed (the composer-detection script may be outdated).","Slow down / back off if rate-limited; avoid rapid repeated postings."],"exampleFix":"// before\nawait ensureComposerOpen(page); // page may be on an error page\n// after\nawait gotoInstagramHome(page);\nawait page.wait({ time: 2 });\nawait ensureComposerOpen(page);","handlingStrategy":"retry","validationCode":"await gotoInstagramHome(page);\nif (!page.url().includes('instagram.com')) throw new Error('Not on instagram.com; navigation failed');","typeGuard":null,"tryCatchPattern":"try { await reel(args); } catch (e) { if (e.message.includes('Failed to open Instagram reel composer')) { await new Promise(r => setTimeout(r, 5000)); await gotoInstagramHome(page); return reel(args); } throw e; }","preventionTips":["Wait for instagram.com to fully load before posting","Check the account isn't rate-limited or action-blocked","Keep the library updated for Instagram DOM changes","Post manually once in the same profile to verify posting is allowed"],"tags":["dom-automation","instagram","composer"],"backgroundTag":"dom-automation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}