{"record":{"id":"434bff2383d87835","repo":"jackwener/OpenCLI","slug":"instagram-reel-editor-did-not-appear","errorCode":null,"errorMessage":"Instagram reel editor did not appear","messagePattern":"Instagram reel editor did not appear","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/reel.js","lineNumber":278,"sourceCode":"        return { state: 'composer', detail: text };\n      }\n      if (/edit|cover photo|trim|video has no audio/.test(lower) && hasVisibleButton(['next'])) {\n        return { state: 'edit', detail: text };\n      }\n      if (/crop|select crop|open media gallery/.test(lower) && hasVisibleButton(['next'])) {\n        return { state: 'crop', detail: text };\n      }\n      return { state: 'pending', detail: text };\n    })()\n  `;\n}\nasync function waitForReelStage(page, expected, maxWaitSeconds = 20) {\n    for (let attempt = 0; attempt < maxWaitSeconds * 2; attempt += 1) {\n        const result = await page.evaluate(buildInspectReelStageJs());\n        if (result?.state === expected)\n            return;\n        if (result?.state === 'failed') {\n            throw new CommandExecutionError('Instagram reel editor did not appear', result.detail ? `Instagram reel flow failed: ${result.detail}` : 'Instagram reel flow failed before the next editor stage');\n        }\n        if (attempt < maxWaitSeconds * 2 - 1)\n            await page.wait({ time: 0.5 });\n    }\n    throw new CommandExecutionError(`Instagram reel ${expected} editor did not appear`);\n}\nasync function focusCaptionEditor(page) {\n    const result = 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      };","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/reel.js#L260-L296","documentation":"waitForReelStage polls buildInspectReelStageJs() twice per second for maxWaitSeconds until the detected stage equals `expected`. If the inspector reports state 'failed', it throws CommandExecutionError('Instagram reel editor did not appear') carrying Instagram's dialog detail. This means the reel flow explicitly broke before reaching the requested editor stage.","triggerScenarios":"During polling, page.evaluate(buildInspectReelStageJs()) returns {state:'failed'} — Instagram rendered a failure dialog before the expected editor stage appeared.","commonSituations":"Instagram rejects the previous step (e.g. share/publish fails due to rate limiting or media rules); session becomes invalid mid-flow; the video was removed or flagged; an unexpected popup derails the flow and the inspector classifies it as failed.","solutions":["Read the detail message: it contains Instagram's failure dialog text.","Check the account for action blocks/rate limits and slow down posting frequency.","Re-authenticate the browser session (cookies/login) if the flow died on a login wall.","Verify the video still meets reel specs and retry with a compliant file.","Update buildInspectReelStageJs detection if Instagram's failure UI changed and is being misclassified."],"exampleFix":"// before\nawait waitForReelStage(page, 'caption'); // fails: session expired mid-flow\n// after\nawait ensureLoggedIn(page); // refresh session before starting the reel flow\nawait waitForReelStage(page, 'caption');","handlingStrategy":"try-catch","validationCode":"// Confirm session health before starting the reel flow\nconst session = await page.evaluate(() => ({\n  loggedIn: !!document.querySelector('svg[aria-label=\"Home\"], nav a[href=\"/\"]'),\n  dialogText: document.querySelector('[role=\"dialog\"]')?.innerText || ''\n}));\nif (!session.loggedIn || session.dialogText) throw new Error('Resolve session/dialog before reel flow');","typeGuard":"function isReelStageResult(r) {\n  return !!r && typeof r === 'object' && typeof r.state === 'string' &&\n    (r.detail === undefined || typeof r.detail === 'string');\n}","tryCatchPattern":"try {\n  await waitForReelStage(page, expected);\n} catch (err) {\n  if (String(err.message).includes('editor did not appear')) {\n    console.error('Reel flow failed:', err.secondary || err.message);\n    // address rate limit / session / media issue, then retry once\n  } else throw err;\n}","preventionTips":["Read the detail message — it quotes Instagram's failure dialog","Keep posting volume under rate-limit thresholds","Refresh login/cookies before long automation runs","Validate media compliance before starting the flow"],"tags":["instagram","editor","flow-failure","puppeteer","automation"],"backgroundTag":"upload-rejected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}