jackwener/OpenCLI · error · CommandExecutionError
Instagram did not persist the ${shouldLike ? 'like' : 'unlik
Error message
Instagram did not persist the ${shouldLike ? 'like' : 'unlike'} on ${expectedPost.code} What it means
After clicking the like control, confirmPersistedState re-reads the snapshot and checks that the post's liked flag now equals the desired state. This throw fires when the click was found and performed but the state did not persist — Instagram silently rejected the action (e.g. rate limiting, login wall, action blocked).
Source
Thrown at clis/instagram/_shared/post-like.js:166
const post = snapshot.posts[index - 1];
if (!post) {
throw new EmptyResultError(command, snapshot.posts.length === 0
? `No visible posts for ${username}; check the username and whether the account is private.`
: `Post index ${index} not found; ${username} has ${snapshot.posts.length} recent posts.`);
}
return post;
}
async function confirmPersistedState(page, username, index, command, expectedPost, shouldLike) {
const confirmed = pickPost(await readPostSnapshot(page, username, index, command), username, index, command);
if (confirmed.code !== expectedPost.code || confirmed.pk !== expectedPost.pk) {
throw new CommandExecutionError(
`Instagram post feed no longer shows the expected post ${expectedPost.code} at index ${index}`,
'The profile feed may have re-rendered or changed order; retry after checking the post in the browser.',
);
}
if (confirmed.liked !== shouldLike) {
throw new CommandExecutionError(
`Instagram did not persist the ${shouldLike ? 'like' : 'unlike'} on ${expectedPost.code}`,
'The action may have been rejected. Retry later, or check the post in the browser.',
);
}
return confirmed;
}
export async function setInstagramPostLike(page, kwargs, shouldLike) {
const username = String(kwargs.username || '').trim();
const index = kwargs.index;
const command = shouldLike ? 'instagram like' : 'instagram unlike';
if (!username) {
throw new ArgumentError('username is required');
}
if (!Number.isInteger(index) || index < 1) {
throw new ArgumentError('--index must be a positive integer', 'e.g. --index 2 for the second most recent post');
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Wait and retry later — rejection is often temporary rate limiting
- Verify the session is still logged in (manually open the post in the automated browser)
- Slow down automation: add sleeps between actions and reduce like volume
- Check whether the account is action-blocked by Instagram and stop automating until the block lifts
Example fix
null
Defensive patterns
Strategy: retry
Validate before calling
// confirm the session can like by checking a known liked state first
const snap = await readPostSnapshot(page, username, index, command);
if (!snap.posts.length) throw new Error('no posts; session may be limited'); Try / catch
try { await setInstagramPostLike(page, kwargs, true); } catch (e) { if (/did not persist/.test(e.message)) { await sleep(60000); /* back off, then retry once */ } else throw e; } Prevention
- Rate-limit like/unlike actions (e.g. one per several seconds)
- Keep the browser session logged in and human-like (no aggressive headless flags)
- Stop and back off if rejections repeat — the account may be action-blocked
- Verify manually in the browser that likes are sticking before resuming automation
When it happens
Trigger: click.already or click.found succeeded but the follow-up snapshot still shows liked !== shouldLike — Instagram's like endpoint failed server-side, the account is action-blocked/rate-limited, or the click hit a login prompt overlay that ate the event.
Common situations: Liking too many posts too quickly triggering Instagram rate limiting; session expired mid-run so clicks go to a login overlay; bot-detection shadow-rejecting the action; temporary Instagram server errors.
Related errors
- 12306 queryByTrainNo returned HTTP ${resp.status}
- amazon ${action} hit a robot check
- Instagram post feed returned malformed payload for ${usernam
- Instagram post feed returned no valid owner id for ${usernam
- Instagram post feed returned malformed items for ${username}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a167ea094ed0b41f.
Report an issue: GitHub.