{"record":{"id":"80707a3988b724fe","repo":"jackwener/OpenCLI","slug":"grok-composer-rejected-the-prompt-json-stringif","errorCode":null,"errorMessage":"Grok composer rejected the prompt: ${JSON.stringify(sendResult)}","messagePattern":"Grok composer rejected the prompt: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/grok/image.js","lineNumber":267,"sourceCode":"    const timeoutMs = (kwargs.timeout || 240) * 1000;\n    const newChat = normalizeBooleanFlag(kwargs.new);\n    const minCount = normalizePositiveInteger(kwargs.count, 1, 'count');\n    const outDir = (kwargs.out || '').toString().trim();\n\n    if (newChat) {\n      await page.goto(GROK_URL);\n      await page.wait(2);\n      await tryStartFreshChat(page);\n      await page.wait(2);\n    } else if (!(await isOnGrok(page))) {\n      await page.goto(GROK_URL);\n      await page.wait(3);\n    }\n\n    const baselineBubbleCount = (await getBubbleImageSets(page)).length;\n    const sendResult = await sendPrompt(page, prompt);\n    if (!sendResult || !sendResult.ok) {\n      throw new CommandExecutionError(\n        `Grok composer rejected the prompt: ${JSON.stringify(sendResult)}`,\n        SESSION_HINT,\n      );\n    }\n\n    const startTime = Date.now();\n    let lastSignature = '';\n    let stableCount = 0;\n    let lastImages = [];\n\n    while (Date.now() - startTime < timeoutMs) {\n      await page.wait(3);\n      const bubbleImageSets = await getBubbleImageSets(page);\n      const images = pickLatestImageCandidate(bubbleImageSets, baselineBubbleCount);\n\n      if (images.length >= minCount) {\n        const signature = imagesSignature(images);\n        if (signature === lastSignature) {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/image.js#L249-L285","documentation":"After typing the prompt into the Grok composer, sendPrompt reports whether submission succeeded; if it returns falsy or {ok:false}, this CommandExecutionError is thrown with the raw sendResult serialized. It means Grok's composer did not accept or submit the prompt, and the SESSION_HINT guides the user toward session/browser-state problems.","triggerScenarios":"sendPrompt returns {ok:false} or null because the composer textarea was not found, the send button was disabled, or submission did not register after waiting 3 page-seconds.","commonSituations":"Grok UI redesign moving composer selectors, a modal/upsell dialog covering the composer, rate-limit or quota banner replacing the input, or the page rendering a logged-out state.","solutions":["Reload the grok.com tab, confirm the composer is visible and you are logged in, then retry.","Check the serialized sendResult in the message for the specific failing step.","Dismiss any dialogs/banners overlaying the composer.","Update the library if Grok's DOM changed (stale selectors)."],"exampleFix":"// before\nsendPrompt(page, prompt) // -> {ok:false, step:'send-button-disabled'}\n// after\n// close the overlay dialog in the tab / log in again, then re-run the send command","handlingStrategy":"try-catch","validationCode":"// Ensure the composer is present before sending:\nconst hasComposer = await page.waitForSelector('textarea', { timeout: 5000 }).catch(() => null);\nif (!hasComposer) throw new Error('Grok composer not found — check session and UI state');","typeGuard":null,"tryCatchPattern":"try {\n  await cli.image({ prompt, outDir });\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('Grok composer rejected the prompt')) {\n    const payload = e.message.match(/\\{.*\\}/s)?.[0];\n    console.error('Composer rejected prompt; sendResult =', payload);\n  } else throw e;\n}","preventionTips":["Dismiss modal dialogs/banners before automating the composer.","Keep the library updated against Grok UI changes.","Confirm login state before each automation run.","Log sendResult payloads to diagnose which composer step failed."],"tags":["browser-automation","ui-selector","session"],"backgroundTag":"browser-automation-selector-failure","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}