{"record":{"id":"3e6004ba4868558c","repo":"jackwener/OpenCLI","slug":"instagram-action-button-not-found-labels-join-3e6004","errorCode":null,"errorMessage":"Instagram action button not found: ${labels.join(' / ')}","messagePattern":"Instagram action button not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/reel.js","lineNumber":227,"sourceCode":"        const result = await page.evaluate(buildInspectUploadStageJs());\n        lastDetail = String(result?.detail || '').trim();\n        if (result?.state === 'preview')\n            return;\n        if (result?.state === 'failed') {\n            throw new CommandExecutionError('Instagram reel upload failed', result.detail ? `Instagram rejected the reel upload: ${result.detail}` : 'Instagram rejected the reel upload before the preview stage');\n        }\n        if (attempt < maxWaitSeconds * 2 - 1)\n            await page.wait({ time: 0.5 });\n    }\n    await page.screenshot({ path: '/tmp/instagram_reel_preview_debug.png' });\n    throw new CommandExecutionError('Instagram reel preview did not appear after upload', lastDetail\n        ? `Inspect /tmp/instagram_reel_preview_debug.png. Last visible dialog text: ${lastDetail}`\n        : 'Inspect /tmp/instagram_reel_preview_debug.png for the upload state');\n}\nasync function clickAction(page, labels, scope = 'any') {\n    const result = await page.evaluate(buildClickActionJs(labels, scope));\n    if (!result?.ok) {\n        throw new CommandExecutionError(`Instagram action button not found: ${labels.join(' / ')}`);\n    }\n    return result.label || labels[0] || '';\n}\nasync function clickActionMaybe(page, labels, scope = 'any') {\n    const result = await page.evaluate(buildClickActionJs(labels, scope));\n    return !!result?.ok;\n}\nfunction buildInspectReelStageJs() {\n    return `\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;","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/reel.js#L209-L245","documentation":"clickAction runs buildClickActionJs to find and click one of the given labeled buttons in the Instagram reel flow. If the evaluate result is not ok, it throws CommandExecutionError with the joined label list. It means none of the requested buttons existed or was clickable at that point in the flow.","triggerScenarios":"clickAction(page, labels, scope) is called (e.g. 'Next', 'Share') and buildClickActionJs returns {ok:false} because no visible/enabled button matching any label (within scope) is present in the DOM.","commonSituations":"Instagram renamed/translated buttons (locale-dependent labels); the flow is on a different step than expected (previous stage skipped or delayed); an interstitial dialog (rate-limit, error, save-draft prompt) covers the button; the wrong scope ('any' vs specific dialog) misses the button's container.","solutions":["Check what the page actually shows (screenshot/DOM) — the flow likely isn't on the expected step.","Add the current Instagram label variants to the labels array, including the account's language (e.g. ['Next','Next','Next']).","Wait for the target stage (waitForReelStage) before calling clickAction so the button exists.","Use clickActionMaybe with your own retry loop for buttons that appear conditionally (e.g. 'Save draft' prompt).","Update buildClickActionJs selectors if Instagram changed the button DOM structure."],"exampleFix":"// before\nawait clickAction(page, ['Next']);\n// after\nawait waitForReelStage(page, 'caption');\nawait clickActionMaybe(page, ['Save draft']) || null;\nawait clickAction(page, ['Next', 'Next', 'Next']);","handlingStrategy":"validation","validationCode":"// Wait for the stage first, then verify a button exists before clicking\nawait waitForReelStage(page, 'caption');\nconst hasBtn = await page.evaluate(buildClickActionJs(labels, scope));\nif (!hasBtn?.ok) throw new Error(`Skipping click: none of [${labels}] present — check current step`);","typeGuard":"function isClickOk(r) {\n  return !!r && typeof r === 'object' && r.ok === true &&\n    (r.label === undefined || typeof r.label === 'string');\n}","tryCatchPattern":"try {\n  return await clickAction(page, labels, scope);\n} catch (err) {\n  if (String(err.message).startsWith('Instagram action button not found')) {\n    await page.screenshot({ path: '/tmp/ig_click_miss.png' });\n    throw new Error(`${err.message} — see /tmp/ig_click_miss.png for actual page state`);\n  }\n  throw err;\n}","preventionTips":["Call waitForReelStage before clickAction so the button is guaranteed rendered","Include multilingual/current label variants in the labels array","Prefer clickActionMaybe with a short retry loop for conditionally shown buttons","Re-verify selectors after Instagram UI rollouts"],"tags":["instagram","ui-automation","button-not-found","puppeteer"],"backgroundTag":"element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}