jackwener/OpenCLI · error · CommandExecutionError
Instagram reel caption did not stick before sharing
Error message
Instagram reel caption did not stick before sharing
What it means
After inserting the caption text, ensureCaptionFilled polls captionMatches up to 6 times (0.5s apart, ~3s total) comparing the editor content (whitespace/nbsp-normalized) with the intended caption. If the editor content never equals the requested caption before the Share step, the library aborts with this error to avoid publishing a reel with a missing or truncated caption.
Source
Thrown at clis/instagram/reel.js:574
clipboardData: dt,
bubbles: true,
cancelable: true,
}));
editor.blur();
return { ok: true, mode: 'contenteditable' };
}
return { ok: false };
})(${JSON.stringify(content)})
`);
}
async function ensureCaptionFilled(page, content) {
for (let attempt = 0; attempt < 6; attempt += 1) {
if (await captionMatches(page, content))
return;
if (attempt < 5)
await page.wait({ time: 0.5 });
}
throw new CommandExecutionError('Instagram reel caption did not stick before sharing');
}
function buildReelPublishStatusProbeJs() {
return `
(() => {
const isVisible = (el) => {
if (!(el instanceof HTMLElement)) return false;
const style = window.getComputedStyle(el);
const rect = el.getBoundingClientRect();
return style.display !== 'none'
&& style.visibility !== 'hidden'
&& rect.width > 0
&& rect.height > 0;
};
const dialogs = Array.from(document.querySelectorAll('[role="dialog"]')).filter((el) => isVisible(el));
const dialogText = dialogs.map((el) => (el.textContent || '').replace(/\\s+/g, ' ').trim()).join(' ');
const lower = dialogText.toLowerCase();
const url = window.location.href;
const sharingVisible = /sharing/.test(lower);View on GitHub (pinned to 49907e53dc)
Solutions
- Simplify the caption: remove @mentions/#hashtags/emoji and retry to see if entity transformation is the cause.
- Retry the run; a dialog re-render mid-insert can wipe the text and a second attempt often sticks.
- Check the caption for characters that get normalized differently (non-breaking spaces, RTL marks, zero-width chars) and strip them.
- Update the library if Instagram changed the editor DOM, so captionMatches reads the correct Lexical/text content.
Example fix
// before
const caption = "New reel! @instagram check it out \u00a0\u2028 thanks";
await run({ caption });
// after
const caption = "New reel! check it out thanks"; // plain text, no entities or exotic whitespace
await run({ caption }); Defensive patterns
Strategy: validation
Validate before calling
// pre-normalize the caption the same way the library does before submitting
const normalized = (s) => s.replace(/\u00a0/g, ' ').replace(/\s+/g, ' ').trim();
if (normalized(caption) !== caption.trim()) {
caption = normalized(caption); // avoid nbsp/whitespace mismatch on verification
} Type guard
null
Try / catch
try {
await client.shareReel({ videoPath, caption });
} catch (err) {
if (String(err.message).includes('caption did not stick')) {
console.error('Caption not applied; reel not shared, safe to retry with plain-text caption');
} else throw err;
} Prevention
- Use plain-text captions without @mention/#hashtag entities or exotic unicode
- Strip non-breaking spaces and zero-width characters before submitting
- Keep captions reasonably short to reduce editor transformation surprises
- Pin/update the library version together with observed Instagram UI changes
When it happens
Trigger: captionMatches() returns false for all 6 attempts after page.insertText(content): the text never landed in the editor, was cleared by Instagram, or normalization (e.g. emoji, mention autocomplete, nbsp handling) makes the DOM text differ from the input.
Common situations: Captions containing @mentions or #hashtags where Instagram transforms the text into mention/entity nodes that don't serialize back to the raw string, captions with unusual unicode that insertText mangles, an Instagram UI update changing the Lexical editor structure so captionMatches reads the wrong node, or a re-render of the dialog wiping the inserted text.
Related errors
- Instagram reel caption editor did not appear
- Instagram reel share confirmation did not appear
- Failed to fetch Instagram media metadata
- Instagram media metadata returned malformed result
- Instagram follow returned invalid JSON
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f3844393d810eb41.
Report an issue: GitHub.