{"record":{"id":"67148d9b1ccc2f9a","repo":"jackwener/OpenCLI","slug":"failed-to-fill-instagram-caption","errorCode":null,"errorMessage":"Failed to fill Instagram caption","messagePattern":"Failed to fill Instagram caption","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/post.js","lineNumber":1168,"sourceCode":"          const range = document.createRange();\n          range.selectNodeContents(editor);\n          selection.addRange(range);\n        }\n        const dt = new DataTransfer();\n        dt.setData('text/plain', content);\n        editor.dispatchEvent(new ClipboardEvent('paste', {\n          clipboardData: dt,\n          bubbles: true,\n          cancelable: true,\n        }));\n        return { ok: true, mode: 'contenteditable', value: editor.textContent || '' };\n      }\n\n      return { ok: false };\n    })(${JSON.stringify(content)})\n  `);\n    if (!result?.ok) {\n        throw new CommandExecutionError('Failed to fill Instagram caption');\n    }\n}\nasync function captionMatches(page, content) {\n    const result = await page.evaluate(`\n    ((content) => {\n      const normalized = content.trim();\n      const readLexicalText = (node) => {\n        if (!node || typeof node !== 'object') return '';\n        if (node.type === 'text' && typeof node.text === 'string') return node.text;\n        if (!Array.isArray(node.children)) return '';\n        if (node.type === 'root') {\n          return node.children.map((child) => readLexicalText(child)).join('\\\\n');\n        }\n        if (node.type === 'paragraph') {\n          return node.children.map((child) => readLexicalText(child)).join('');\n        }\n        return node.children.map((child) => readLexicalText(child)).join('');\n      };","sourceCodeStart":1150,"sourceCodeEnd":1186,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/post.js#L1150-L1186","documentation":"fillCaption evaluates in-page JS that types/sets the caption content into the editor and returns { ok:false } on failure; the library then throws this error. It means the caption text could not be entered into the editor element.","triggerScenarios":"The caption-fill page.evaluate returns ok:false — editor element not found, contenteditable not focusable, or the set-value script was rejected by the page.","commonSituations":"Editor is a contenteditable that rejects direct value assignment, emoji/unicode caption tripping the injection script, an emoji picker or suggestion dropdown stealing focus, or a page navigation mid-fill.","solutions":["Retry the post; focus-stealing dropdowns are often transient","Simplify the caption (strip unusual emoji or control characters) to test whether content is the cause","Screenshot the editor state to confirm the caption editor is still open","Update the CLI if the caption-fill script no longer matches the editor element"],"exampleFix":"// before\nawait fillCaption(page, 'Launch day! \\u{1F680}\\u200D\\u{1F4A5} #now'); // ZWJ sequence\n// after\nawait fillCaption(page, 'Launch day! 🚀 #now'); // simpler caption fills cleanly","handlingStrategy":"try-catch","validationCode":"if ([...content].length > 2200) throw new Error('Caption exceeds Instagram limit');","typeGuard":"function isFillableCaption(s) { return typeof s === 'string' && s.trim().length > 0 && [...s].length <= 2200; }","tryCatchPattern":"try {\n  await fillCaption(page, content);\n} catch (e) {\n  if (String(e.message).includes('Failed to fill Instagram caption')) {\n    await page.evaluate(() => document.activeElement?.blur());\n    await page.wait({ time: 1 });\n    await fillCaption(page, content);\n  } else throw e;\n}","preventionTips":["Keep captions within the 2,200-character limit","Test captions with complex emoji separately before production runs","Blur/close suggestion dropdowns before filling the editor"],"tags":["instagram","caption","ui-automation"],"backgroundTag":"form-fill-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}