{"record":{"id":"5edd40c60cf1df8c","repo":"jackwener/OpenCLI","slug":"instagram-caption-did-not-stick-before-sharing","errorCode":null,"errorMessage":"Instagram caption did not stick before sharing","messagePattern":"Instagram caption did not stick before sharing","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/post.js","lineNumber":1239,"sourceCode":"        return { ok: false, text, counter: counter || '' };\n      }\n\n      return { ok: false };\n    })(${JSON.stringify(content)})\n  `);\n    return !!result?.ok;\n}\nasync function ensureCaptionFilled(page, content) {\n    for (let attempt = 0; attempt < 6; attempt++) {\n        if (await captionMatches(page, content)) {\n            return;\n        }\n        if (attempt < 5) {\n            await page.wait({ time: 0.5 });\n        }\n    }\n    await page.screenshot({ path: '/tmp/instagram_post_caption_fill_debug.png' });\n    throw new CommandExecutionError('Instagram caption did not stick before sharing', 'Inspect /tmp/instagram_post_caption_fill_debug.png for the caption editor state');\n}\nasync function waitForPublishSuccess(page) {\n    let settledStreak = 0;\n    for (let attempt = 0; attempt < 90; attempt++) {\n        const result = await page.evaluate(buildPublishStatusProbeJs());\n        if (result?.failed) {\n            await page.screenshot({ path: '/tmp/instagram_post_share_debug.png' });\n            throw new CommandExecutionError('Instagram post share failed', 'Inspect /tmp/instagram_post_share_debug.png for the share failure state');\n        }\n        if (result?.ok) {\n            return result.url || '';\n        }\n        if (result?.settled) {\n            settledStreak += 1;\n            if (settledStreak >= 3)\n                return '';\n        }\n        else {","sourceCodeStart":1221,"sourceCodeEnd":1257,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/post.js#L1221-L1257","documentation":"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.","triggerScenarios":"The verify loop after caption fill exhausts attempts (attempt 5 is the last wait) with captionMatches(page, content) still false, then screenshots and throws.","commonSituations":"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.","solutions":["Inspect /tmp/instagram_post_caption_fill_debug.png to see what the editor actually contains","Shorten the caption to under Instagram's limit (2,200 chars) and remove problematic characters","Retry; slow async editor updates sometimes exceed the verification window","Avoid pasting text that triggers autolink rewrites (unusual mentions/hashtags) mid-caption","Update the CLI if the caption comparison logic needs adjusting for a UI change"],"exampleFix":"// before\nawait fillCaption(page, 'x'.repeat(2500)); // over limit, gets truncated\n// after\nconst caption = 'x'.repeat(2500).slice(0, 2200);\nawait fillCaption(page, caption); // fits, verification passes","handlingStrategy":"try-catch","validationCode":"if ([...content].length > 2200) throw new Error('Caption would be truncated; verification will fail');","typeGuard":null,"tryCatchPattern":"try {\n  await verifyCaptionAndShare(page, content);\n} catch (e) {\n  if (String(e.message).includes('caption did not stick')) {\n    // see /tmp/instagram_post_caption_fill_debug.png\n    await refillCaption(page, content);\n  } else throw e;\n}","preventionTips":["Keep captions comfortably under the length limit so nothing is truncated","Avoid characters that trigger autolink/mention rewrites during verification","If failures cluster on slow machines, extend the verification wait window"],"tags":["instagram","caption","verification-timeout"],"backgroundTag":"form-fill-verification-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}