{"record":{"id":"ab737e9054933641","repo":"jackwener/OpenCLI","slug":"could-not-find-the-like-control-on-post-code","errorCode":null,"errorMessage":"Could not find the like control on ${post.code}","messagePattern":"Could not find the like control on (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/post-like.js","lineNumber":198,"sourceCode":"    }\n    if (!Number.isInteger(index) || index < 1) {\n        throw new ArgumentError('--index must be a positive integer', 'e.g. --index 2 for the second most recent post');\n    }\n\n    const snapshot = await readPostSnapshot(page, username, index, command);\n    const post = pickPost(snapshot, username, index, command);\n    const label = post.caption || `(post #${index})`;\n    const settled = [{ status: shouldLike ? 'Already liked' : 'Already unliked', user: username, post: label }];\n    if (post.liked === shouldLike) return settled;\n\n    await page.goto(`https://www.instagram.com/p/${post.code}/`, { settleMs: 2000 });\n    let click = null;\n    for (let attempt = 0; attempt < 5 && !click?.found; attempt += 1) {\n        if (attempt > 0) await page.sleep(1);\n        click = unwrapEvaluateResult(await page.evaluate(buildToggleLikeJs(shouldLike)));\n    }\n    if (!click?.found) {\n        throw new CommandExecutionError(\n            `Could not find the like control on ${post.code}`,\n            'Open the post in the browser and check whether Instagram is asking you to log in, or set the interface language to English.',\n        );\n    }\n    if (click.already) {\n        await confirmPersistedState(page, username, index, command, post, shouldLike);\n        return settled;\n    }\n\n    for (let attempt = 0; attempt < 5; attempt += 1) {\n        await page.sleep(1);\n        if (unwrapEvaluateResult(await page.evaluate(buildReadLikeStateJs(shouldLike))) !== true) continue;\n        // A rejected action reverts the icon shortly after the optimistic flip.\n        await page.sleep(2);\n        if (unwrapEvaluateResult(await page.evaluate(buildReadLikeStateJs(shouldLike))) === true) {\n            await confirmPersistedState(page, username, index, command, post, shouldLike);\n            return [{ status: shouldLike ? 'Liked' : 'Unliked', user: username, post: label }];\n        }","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/post-like.js#L180-L216","documentation":"After selecting the post, the library runs buildToggleLikeJs up to 5 times (sleeping 1s between attempts) to locate the post's like control in the page. This throw fires when all 5 attempts return click.found === false, meaning the like button/selector could not be found at all — usually because the page is not showing the post view the script expects.","triggerScenarios":"Instagram showing a login wall or signup modal instead of the post; non-English interface language changing aria-labels/selectors the script matches on; the post detail view failing to open; DOM structure changes from Instagram updates.","commonSituations":"Expired or logged-out sessions hitting the login prompt; browsers set to a non-English locale; headless environment where the post modal never renders; recently changed Instagram DOM breaking selectors.","solutions":["Open the post in the automated browser and confirm it is not showing a login prompt; re-authenticate if needed","Set the browser/interface language to English","Retry later — temporary Instagram UI experiments can hide the control","Update the library/buildToggleLikeJs selectors to match the current DOM"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// pre-check that the post view is interactive, not a login wall\nconst bodyText = await page.evaluate(() => document.body.innerText);\nif (/log in|sign up/i.test(bodyText.slice(0, 500))) throw new Error('login wall detected; re-authenticate first');","typeGuard":"function likeControlVisible(page) { return page.evaluate(() => !!document.querySelector('svg[aria-label=\"Like\"], button[aria-label=\"Like\"]')); }","tryCatchPattern":"try { await setInstagramPostLike(page, kwargs, true); } catch (e) { if (/Could not find the like control/.test(e.message)) { /* check login state & language, then retry once */ await ensureLoggedIn(page); return setInstagramPostLike(page, kwargs, true); } throw e; }","preventionTips":["Keep the browser session authenticated before automating likes","Set the browser locale/interface language to English","Ensure the post detail view fully opens before acting (add settle sleeps)","Update library selectors when Instagram ships DOM changes"],"tags":["instagram","selector-not-found","scraping","puppeteer"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}