{"record":{"id":"17501ffe7c32beb2","repo":"jackwener/OpenCLI","slug":"instagram-note-publish-failed-at-string-result","errorCode":null,"errorMessage":"Instagram note publish failed at ${String(result?.stage || 'unknown')}: ${String(result?.text || 'unknown error')}","messagePattern":"Instagram note publish failed at (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/note.js","lineNumber":219,"sourceCode":"    access: 'write',\n    description: 'Publish a text Instagram note',\n    domain: 'www.instagram.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'content', positional: true, required: true, help: 'Note text (max 60 characters)' },\n        { name: 'timeout', type: 'int', required: false, default: 120, help: 'Max seconds for the overall command (default: 120)' },\n    ],\n    columns: ['status', 'detail', 'noteId'],\n    validateArgs: validateInstagramNoteArgs,\n    func: async (page, kwargs) => {\n        const browserPage = requirePage(page);\n        const content = normalizeInstagramNoteContent(kwargs);\n        await browserPage.goto(INSTAGRAM_INBOX_URL);\n        await browserPage.wait({ time: 2 });\n        const result = await browserPage.evaluate(buildPublishInstagramNoteJs(content));\n        if (!result?.ok) {\n            throw new CommandExecutionError(`Instagram note publish failed at ${String(result?.stage || 'unknown')}: ${String(result?.text || 'unknown error')}`);\n        }\n        return buildNoteSuccessResult(String(result.noteId || ''));\n    },\n});\n","sourceCodeStart":201,"sourceCodeEnd":224,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/note.js#L201-L224","documentation":"This CommandExecutionError is thrown after the CLI evaluates in-browser JavaScript to publish an Instagram note and the injected script reports ok:false. The injected script returns a stage ('goto', 'composer', 'publish', etc.) plus diagnostic text (often Instagram's own error message), and the CLI surfaces both so you know which step of the UI automation failed. It means the note was NOT published and Instagram's DOM did not confirm success at the reported stage.","triggerScenarios":"Running the 'instagram note' command (clis/instagram/note.js) when the in-page publish script's result has ok falsy: Instagram's composer never opened (stage 'composer'), the share/publish click failed (stage 'publish'), the page returned an error/toast text, or a DOM element the script expected was missing (e.g. logged out, rate-limited, or Instagram UI changed).","commonSituations":"Instagram session expired or not logged into the browser profile; note content violating Instagram rules (rejection toast); Instagram rolled out a DOM change breaking the selector-based script; network slowness so the composer hadn't rendered within the script's waits; account restricted from posting notes (rate limit / temporary block).","solutions":["Re-authenticate: open a browser session for www.instagram.com, log in, and verify the inbox page loads before retrying the command.","Read the stage/text in the error message: 'composer' means the note composer never appeared (login/UI problem); 'publish' with Instagram text means Instagram rejected it (content/rate limit).","Retry after waiting a few minutes if the text mentions try-again or rate limiting; Instagram notes are heavily rate-limited.","Keep the note to 60 characters or fewer (the CLI validates max 60) and avoid content Instagram may flag.","If it persists after login works manually, the Instagram DOM likely changed — update the CLI/library to a version with updated selectors in buildPublishInstagramNoteJs.","Increase --timeout (default 120s) if the page is slow to load so the script has time to find the composer."],"exampleFix":"// before: calling without a valid browser session/login\nawait cli.run('instagram note', { content: 'hello' });\n// after: ensure login first, then retry with backoff\nawait cli.run('open browser', { site: 'instagram' }); // log in interactively if needed\ntry {\n  await cli.run('instagram note', { content: 'hello', timeout: 180 });\n} catch (e) {\n  if (String(e.message).includes('Instagram note publish failed')) {\n    await sleep(60000); // back off on rate limit/UI flake, then retry once\n    await cli.run('instagram note', { content: 'hello', timeout: 180 });\n  }\n}","handlingStrategy":"try-catch","validationCode":"// Before invoking, confirm the session works and content is valid\nif (!page) throw new Error('Browser session required');\nconst content = String(kwargs.content || '').trim();\nif (!content || content.length > 60) throw new Error('Note content must be 1-60 characters');\nawait page.goto('https://www.instagram.com/');\nconst loggedIn = await page.evaluate(() => !document.querySelector('input[name=\"username\"]'));\nif (!loggedIn) throw new Error('Not logged into Instagram — authenticate first');","typeGuard":"function isPublishOk(result) {\n  return !!result && typeof result === 'object' && result.ok === true && typeof result.noteId === 'string';\n}","tryCatchPattern":"try {\n  const result = await cli.run('instagram note', { content: 'hello', timeout: 180 });\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.startsWith('Instagram note publish failed')) {\n    const m = e.message.match(/failed at (\\w+): (.*)/);\n    console.error(`Stage=${m?.[1]} reason=${m?.[2]}`);\n    if (m?.[2]?.match(/try again|rate limit/i)) await sleep(60000); // backoff then retry once\n    else throw e; // login/UI breakage — do not blind-retry\n  } else throw e;\n}","preventionTips":["Verify the Instagram session is logged in before write commands","Keep note text within 60 characters","Use a generous --timeout (180s+) on slow networks","Space out note posts — Instagram rate-limits notes aggressively","Keep the CLI updated since Instagram DOM changes break the injected script","Parse the stage from the error message to decide retry vs. fix-auth"],"tags":["instagram","browser-automation","ui-strategy","publish-failed"],"backgroundTag":"instagram-note-publish-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}