jackwener/OpenCLI · error · CommandExecutionError

Instagram caption did not stick before sharing

Error message

Instagram caption did not stick before sharing

What it means

After filling the caption, the library re-reads the editor up to 6 times (0.5s apart) to verify the text 'stuck'. If captionMatches never passes, it saves /tmp/instagram_post_caption_fill_debug.png and throws this error rather than sharing a post with a missing caption.

Source

Thrown at clis/instagram/post.js:1239

        return { ok: false, text, counter: counter || '' };
      }

      return { ok: false };
    })(${JSON.stringify(content)})
  `);
    return !!result?.ok;
}
async function ensureCaptionFilled(page, content) {
    for (let attempt = 0; attempt < 6; attempt++) {
        if (await captionMatches(page, content)) {
            return;
        }
        if (attempt < 5) {
            await page.wait({ time: 0.5 });
        }
    }
    await page.screenshot({ path: '/tmp/instagram_post_caption_fill_debug.png' });
    throw new CommandExecutionError('Instagram caption did not stick before sharing', 'Inspect /tmp/instagram_post_caption_fill_debug.png for the caption editor state');
}
async function waitForPublishSuccess(page) {
    let settledStreak = 0;
    for (let attempt = 0; attempt < 90; attempt++) {
        const result = await page.evaluate(buildPublishStatusProbeJs());
        if (result?.failed) {
            await page.screenshot({ path: '/tmp/instagram_post_share_debug.png' });
            throw new CommandExecutionError('Instagram post share failed', 'Inspect /tmp/instagram_post_share_debug.png for the share failure state');
        }
        if (result?.ok) {
            return result.url || '';
        }
        if (result?.settled) {
            settledStreak += 1;
            if (settledStreak >= 3)
                return '';
        }
        else {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect /tmp/instagram_post_caption_fill_debug.png to see what the editor actually contains
  2. Shorten the caption to under Instagram's limit (2,200 chars) and remove problematic characters
  3. Retry; slow async editor updates sometimes exceed the verification window
  4. Avoid pasting text that triggers autolink rewrites (unusual mentions/hashtags) mid-caption
  5. Update the CLI if the caption comparison logic needs adjusting for a UI change

Example fix

// before
await fillCaption(page, 'x'.repeat(2500)); // over limit, gets truncated
// after
const caption = 'x'.repeat(2500).slice(0, 2200);
await fillCaption(page, caption); // fits, verification passes
Defensive patterns

Strategy: try-catch

Validate before calling

if ([...content].length > 2200) throw new Error('Caption would be truncated; verification will fail');

Try / catch

try {
  await verifyCaptionAndShare(page, content);
} catch (e) {
  if (String(e.message).includes('caption did not stick')) {
    // see /tmp/instagram_post_caption_fill_debug.png
    await refillCaption(page, content);
  } else throw e;
}

Prevention

When it happens

Trigger: The verify loop after caption fill exhausts attempts (attempt 5 is the last wait) with captionMatches(page, content) still false, then screenshots and throws.

Common situations: Instagram's normalized comparison differing from typed text (autotrim, mention/hashtag linkification), caption truncated by a length limit, a suggestion dropdown rewriting text, or async state update slower than the 3s total window.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/5edd40c60cf1df8c. Report an issue: GitHub.