{"record":{"id":"c384a7aeb76ed29e","repo":"jackwener/OpenCLI","slug":"could-not-submit-the-midjourney-prompt-error-in","errorCode":null,"errorMessage":"Could not submit the Midjourney prompt: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Could not submit the Midjourney prompt: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/generate.js","lineNumber":196,"sourceCode":"    }\n    await closeImagePanel(page);\n\n    let captureReady = false;\n    if (typeof page.installInterceptor === 'function' && typeof page.getInterceptedRequests === 'function') {\n      try {\n        await page.installInterceptor('/api/submit-jobs');\n        await page.getInterceptedRequests();\n        captureReady = true;\n      } catch {}\n    }\n\n    const submittedAt = Date.now();\n    try {\n      const filled = await page.fillText(COMPOSER_SELECTOR, effectivePrompt);\n      if (!filled?.filled || !filled?.verified) throw new Error('composer fill was not verified');\n      await page.pressKey('Enter');\n    } catch (error) {\n      throw new CommandExecutionError(`Could not submit the Midjourney prompt: ${error instanceof Error ? error.message : String(error)}`);\n    }\n\n    const remainingForSubmission = Math.floor(timeout - (Date.now() - commandStartedAt) / 1000);\n    if (remainingForSubmission < 1) throw new TimeoutError('Midjourney job submission', timeout);\n    const submitTimeout = Math.min(remainingForSubmission, 75);\n    let jobIds = [];\n    if (captureReady && typeof page.waitForCapture === 'function') {\n      try {\n        await page.waitForCapture(Math.min(submitTimeout, 20));\n        jobIds = submittedJobIdsFromCaptures(await page.getInterceptedRequests(), plan.repeat, baselineIds);\n      } catch (error) {\n        if (error instanceof CommandExecutionError) throw error;\n      }\n    }\n    if (!jobIds.length) {\n      jobIds = await waitForSubmittedJobsAfter(\n        page,\n        account.user_id,","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/generate.js#L178-L214","documentation":"Wrapping error for any failure during the prompt-submit step: fillText throwing, the fill not being verified, or pressKey('Enter') failing. The original error message is appended after the 'Could not submit the Midjourney prompt: ' prefix and rethrown as CommandExecutionError, so the CLI never leaves the composer in an unknown half-submitted state without explanation.","triggerScenarios":"Any exception inside the try block at generate.js:191-197: page.fillText throws (element missing/detached/timeout), the fill result fails the filled/verified check (see index 2617), or page.pressKey('Enter') fails. The caught error's message becomes the suffix of this message.","commonSituations":"Composer removed by a page re-render mid-fill; Enter keypress blocked by an overlay; browser tab closed or navigated by the user during the command; session expired so the SPA logs out between composer detection and fill.","solutions":["Read the suffix after the colon — it names the underlying cause (fill failure, verification failure, keypress failure)","Re-run the command; most causes are transient UI races","Confirm the Chrome session is signed in and the Imagine page is stable/idle before retrying","If persistent, update opencli in case Midjourney changed the composer behavior"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-checks before generate:\nawait page.wait({ selector: COMPOSER_SELECTOR, timeout: 12 });  // composer present and stable\ndismissOverlays(page);                                          // no modals stealing focus","typeGuard":"function isPromptSubmitError(err) {\n  return err instanceof Error && err.message.startsWith('Could not submit the Midjourney prompt:');\n}","tryCatchPattern":"try {\n  rows = await generate(prompt, opts);\n} catch (e) {\n  if (isPromptSubmitError(e)) {\n    const cause = e.message.split(': ').slice(1).join(': '); // underlying reason\n    console.error(`Submit failed (${cause}); retrying once`);\n    rows = await generate(prompt, opts);\n  } else throw e;\n}","preventionTips":["Parse the message suffix to identify the real cause before retrying","Keep the Imagine tab open and foregrounded in the managed Chrome session","Ensure the session is signed in so the SPA cannot log out mid-command","Retry once; only escalate if it fails repeatedly (suggests a DOM/update change)","Keep opencli updated against Midjourney UI changes"],"tags":["browser-automation","midjourney","submission-failure","wrapped-error"],"backgroundTag":"prompt-submission-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}