jackwener/OpenCLI · error · CommandExecutionError
Instagram post share failed
Error message
Instagram post share failed
What it means
waitForPublishSuccess polls the Instagram composer page up to 90 times with a DOM probe (buildPublishStatusProbeJs). When the probe detects an explicit failure state in the publish dialog, it throws this CommandExecutionError after saving a debug screenshot. It means Instagram itself reported the share as failed (e.g. an in-dialog 'Couldn't post' message), not that the CLI timed out.
Source
Thrown at clis/instagram/post.js:1247
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 {
settledStreak = 0;
}
if (attempt < 89) {
await page.wait({ time: 1 });
}
}
await page.screenshot({ path: '/tmp/instagram_post_share_debug.png' });
throw new CommandExecutionError('Instagram post share confirmation did not appear', 'Inspect /tmp/instagram_post_share_debug.png for the final publish state');View on GitHub (pinned to 49907e53dc)
Solutions
- Open /tmp/instagram_post_share_debug.png to see the exact failure state Instagram showed in the dialog
- Wait and retry later if the dialog shows a rate-limit / 'try again later' message (action block)
- Re-encode/rescale the media (valid JPG/PNG/MP4 within Instagram limits) and retry
- Verify the logged-in session is valid and not restricted (log in manually in the browser session)
- Re-run with OPENCLI_INSTAGRAM_CAPTURE=1 to inspect captured protocol responses for the failing request
Example fix
// before: immediate throw on first failed probe
if (result?.failed) {
await page.screenshot({ path: '/tmp/instagram_post_share_debug.png' });
throw new CommandExecutionError('Instagram post share failed', hint);
}
// after: allow a short retry streak before giving up
if (result?.failed) {
failedStreak += 1;
if (failedStreak >= 3) {
await page.screenshot({ path: '/tmp/instagram_post_share_debug.png' });
throw new CommandExecutionError('Instagram post share failed', hint);
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before posting, confirm the session can reach Instagram's composer without dialogs
const hasDialog = await page.evaluate(`!!document.querySelector('div[role="dialog"]')`);
if (hasDialog) throw new Error('Dismiss open dialogs before posting'); Type guard
function isPublishProbeResult(r) {
return r !== null && typeof r === 'object' && ('ok' in r || 'failed' in r || 'settled' in r);
} Try / catch
try {
await postToInstagram(media, caption);
} catch (e) {
if (e instanceof CommandExecutionError && e.message === 'Instagram post share failed') {
// inspect /tmp/instagram_post_share_debug.png, back off, and retry later
await sleep(rateLimitBackoff);
return retryPost(media, caption);
}
throw e;
} Prevention
- Keep posting volume under Instagram rate limits (space posts minutes apart)
- Pre-validate media size/format/resolution against Instagram limits before sharing
- Use a warmed, regularly-used session rather than a fresh login
- Archive /tmp/instagram_post_share_debug.png from each failure to spot recurring dialog states
When it happens
Trigger: During clis/instagram/post.js share flow: the in-page probe returns result.failed because the publish dialog shows a failure notice after clicking Share — e.g. media upload rejected, rate limit, or Instagram-side post creation error.
Common situations: Instagram rate-limiting or action-block on the account; unsupported media (size/format) rejected server-side; network drop mid-upload; transient Instagram UI/API changes so the probe misreads the dialog; account flagged for suspicious automation.
Related errors
- Instagram note publish failed at ${String(result?.stage || '
- Failed to open Instagram post composer
- Instagram post share confirmation did not appear
- ${uiError.message}
- Instagram reel upload failed
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ea9586f665758944.
Report an issue: GitHub.