jackwener/OpenCLI · error · CommandExecutionError

Midjourney rejected the submitted job: ${detail}

Error message

Midjourney rejected the submitted job: ${detail}

What it means

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.

Source

Thrown at clis/midjourney/utils.js:147

    speed: flag('relax') ? 'relax' : flag('turbo') ? 'turbo' : flag('fast') ? 'fast' : null,
    repeat: parameter('(?:r|repeat)'),
    profile: parameter('(?:p|profile)'),
    draft: flag('draft'),
    raw: flag('raw'),
  });
}

export function submittedJobIdsFromCaptures(captures, expectedCount, baselineIds = new Set()) {
  if (!Array.isArray(captures) || captures.length === 0) return [];
  const successes = captures.flatMap((payload) => Array.isArray(payload?.success) ? payload.success : []);
  const ids = [...new Set(successes
    .map((row) => String(row?.job_id || '').toLowerCase())
    .filter((id) => UUID_RE.test(id) && !baselineIds.has(id)))];
  if (ids.length === expectedCount) return ids;
  const failures = captures.flatMap((payload) => Array.isArray(payload?.failure) ? payload.failure : []);
  if (failures.length && ids.length === 0) {
    const detail = failures.map((row) => row?.message || row?.error || JSON.stringify(row)).join('; ');
    throw new CommandExecutionError(`Midjourney rejected the submitted job: ${detail}`);
  }
  if (successes.length || ids.length) {
    throw new CommandExecutionError(
      `Midjourney submit response was ambiguous; expected ${expectedCount} new job(s), received ${ids.length}`,
    );
  }
  return [];
}

export function uploadedStorageUrlsFromCaptures(captures) {
  if (!Array.isArray(captures)) return [];
  const payloads = captures.flatMap((capture) => [capture, capture?.data, capture?.response].filter(Boolean));
  return [...new Set(payloads.flatMap((payload) => {
    const bucketPathname = String(payload?.bucketPathname || '').replace(/^\/+/, '');
    if (!/^[0-9a-f-]{36}\/[0-9a-f]{32,}\.(?:png|jpe?g|webp|gif)$/i.test(bucketPathname)) return [];
    const thumbnailPath = bucketPathname.replace(/(\.(?:png|jpe?g|webp|gif))$/i, '_384_N$1');
    return [`${MIDJOURNEY_CDN}/u/${thumbnailPath}`];
  }))];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the joined detail message in the error; it contains Midjourney's own rejection reason for each failed row.
  2. Simplify or reword the prompt to remove terms flagged by moderation and retry.
  3. Verify the Midjourney session is valid and the subscription is active (run the account check before submitting).
  4. Retry after a delay if the failure rows indicate rate limiting or queue pressure.

Example fix

// before
await submit(page, '/imagine', promptWithBannedWords);
// after
const sanitized = prompt.replace(/banned-term/gi, 'safe-term');
await submit(page, '/imagine', sanitized);
Defensive patterns

Strategy: validation

Validate before calling

const ids = captures.flatMap(c => Array.isArray(c?.job_id) ? c.job_id : (UUID_RE.test(String(c?.job_id||'')) ? [c.job_id] : []));
const failures = captures.flatMap(c => Array.isArray(c?.failure) ? c.failure : []);
if (failures.length && ids.length === 0) console.error('precheck: submit will be rejected:', failures.map(f => f?.message).join('; '));

Type guard

function isSuccessfulSubmit(payload) {
  return payload != null && typeof payload === 'object' &&
    (!Array.isArray(payload.failure) || payload.failure.length === 0) &&
    typeof payload.job_id === 'string' && /^[0-9a-f-]{36}$/i.test(payload.job_id);
}

Try / catch

try {
  const ids = await submittedJobIdsFromCaptures(page, captures, expected);
} catch (err) {
  if (/Midjourney rejected the submitted job/.test(err.message)) {
    console.error('Prompt rejected:', err.message.replace('Midjourney rejected the submitted job: ', ''));
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/93e0bbca2754a279. Report an issue: GitHub.