{"record":{"id":"93e0bbca2754a279","repo":"jackwener/OpenCLI","slug":"midjourney-rejected-the-submitted-job-detail","errorCode":null,"errorMessage":"Midjourney rejected the submitted job: ${detail}","messagePattern":"Midjourney rejected the submitted job: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":147,"sourceCode":"    speed: flag('relax') ? 'relax' : flag('turbo') ? 'turbo' : flag('fast') ? 'fast' : null,\n    repeat: parameter('(?:r|repeat)'),\n    profile: parameter('(?:p|profile)'),\n    draft: flag('draft'),\n    raw: flag('raw'),\n  });\n}\n\nexport function submittedJobIdsFromCaptures(captures, expectedCount, baselineIds = new Set()) {\n  if (!Array.isArray(captures) || captures.length === 0) return [];\n  const successes = captures.flatMap((payload) => Array.isArray(payload?.success) ? payload.success : []);\n  const ids = [...new Set(successes\n    .map((row) => String(row?.job_id || '').toLowerCase())\n    .filter((id) => UUID_RE.test(id) && !baselineIds.has(id)))];\n  if (ids.length === expectedCount) return ids;\n  const failures = captures.flatMap((payload) => Array.isArray(payload?.failure) ? payload.failure : []);\n  if (failures.length && ids.length === 0) {\n    const detail = failures.map((row) => row?.message || row?.error || JSON.stringify(row)).join('; ');\n    throw new CommandExecutionError(`Midjourney rejected the submitted job: ${detail}`);\n  }\n  if (successes.length || ids.length) {\n    throw new CommandExecutionError(\n      `Midjourney submit response was ambiguous; expected ${expectedCount} new job(s), received ${ids.length}`,\n    );\n  }\n  return [];\n}\n\nexport function uploadedStorageUrlsFromCaptures(captures) {\n  if (!Array.isArray(captures)) return [];\n  const payloads = captures.flatMap((capture) => [capture, capture?.data, capture?.response].filter(Boolean));\n  return [...new Set(payloads.flatMap((payload) => {\n    const bucketPathname = String(payload?.bucketPathname || '').replace(/^\\/+/, '');\n    if (!/^[0-9a-f-]{36}\\/[0-9a-f]{32,}\\.(?:png|jpe?g|webp|gif)$/i.test(bucketPathname)) return [];\n    const thumbnailPath = bucketPathname.replace(/(\\.(?:png|jpe?g|webp|gif))$/i, '_384_N$1');\n    return [`${MIDJOURNEY_CDN}/u/${thumbnailPath}`];\n  }))];","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L129-L165","documentation":"This error is thrown by submittedJobIdsFromCaptures in clis/midjourney/utils.js when every captured submit response contains a 'failure' array and no valid new job UUIDs could be extracted. Midjourney's submit API returned explicit rejection payloads, so the CLI surfaces the per-row failure messages verbatim. It indicates the job was rejected server-side, not a client parsing bug.","triggerScenarios":"After submitting imagine job(s), every capture payload has a non-empty failure array, zero UUIDs pass UUID_RE, ids.length === 0, and the extracted failure count is greater than zero. Each row's message/error field is joined with ';' into the detail string.","commonSituations":"Submitting prompts that violate Midjourney moderation (banned terms), using an expired or invalid job submission endpoint, hitting rate/queue limits, or sending malformed prompt parameters (bad --ar/--v values) that the API rejects with structured failure rows.","solutions":["Read the joined detail message in the error; it contains Midjourney's own rejection reason for each failed row.","Simplify or reword the prompt to remove terms flagged by moderation and retry.","Verify the Midjourney session is valid and the subscription is active (run the account check before submitting).","Retry after a delay if the failure rows indicate rate limiting or queue pressure."],"exampleFix":"// before\nawait submit(page, '/imagine', promptWithBannedWords);\n// after\nconst sanitized = prompt.replace(/banned-term/gi, 'safe-term');\nawait submit(page, '/imagine', sanitized);","handlingStrategy":"validation","validationCode":"const ids = captures.flatMap(c => Array.isArray(c?.job_id) ? c.job_id : (UUID_RE.test(String(c?.job_id||'')) ? [c.job_id] : []));\nconst failures = captures.flatMap(c => Array.isArray(c?.failure) ? c.failure : []);\nif (failures.length && ids.length === 0) console.error('precheck: submit will be rejected:', failures.map(f => f?.message).join('; '));","typeGuard":"function isSuccessfulSubmit(payload) {\n  return payload != null && typeof payload === 'object' &&\n    (!Array.isArray(payload.failure) || payload.failure.length === 0) &&\n    typeof payload.job_id === 'string' && /^[0-9a-f-]{36}$/i.test(payload.job_id);\n}","tryCatchPattern":"try {\n  const ids = await submittedJobIdsFromCaptures(page, captures, expected);\n} catch (err) {\n  if (/Midjourney rejected the submitted job/.test(err.message)) {\n    console.error('Prompt rejected:', err.message.replace('Midjourney rejected the submitted job: ', ''));\n  } else throw err;\n}","preventionTips":["Pre-screen prompts against known moderation-flagged terms before submitting","Verify session and subscription before each submit batch","Log full submit responses to capture failure rows early","Submit small batches so rejections are isolated"],"tags":["midjourney","api-rejection","cli"],"backgroundTag":"api-request-rejected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}