jackwener/OpenCLI · error · CommandExecutionError
Midjourney submit response was ambiguous; expected ${expecte
Error message
Midjourney submit response was ambiguous; expected ${expectedCount} new job(s), received ${ids.length} What it means
Thrown by submittedJobIdsFromCaptures when some submit responses succeeded (successes or extracted ids exist) but fewer valid job UUIDs than expectedCount were recovered. The CLI cannot confirm whether the remaining jobs were created, so it refuses to return a partial result and reports expected vs received counts. This prevents silently losing track of submitted jobs.
Source
Thrown at clis/midjourney/utils.js:150
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}`];
}))];
}
export function isVideoJob(job) {View on GitHub (pinned to 49907e53dc)
Solutions
- Check the captured response payloads for failure rows explaining the missing jobs.
- Resubmit only the missing jobs (diff expected vs received) after a short delay.
- Log full submit responses during development to detect API shape changes.
- Ensure baselineIds does not accidentally contain ids from the current batch.
Example fix
// before const ids = await submittedJobIdsFromCaptures(page, captures, 4); // may throw on 3 of 4 // after const ids = await submittedJobIdsFromCaptures(page, captures, 1); // submit smaller batches per call
Defensive patterns
Strategy: validation
Validate before calling
const ids = captures.flatMap(c => [String(c?.job_id||'')]).filter(id => UUID_RE.test(id));
if (ids.length !== expectedCount) console.warn(`precheck mismatch: expected ${expectedCount}, got ${ids.length}`); Type guard
function isCompleteSubmitBatch(captures, expectedCount) {
const ids = new Set(captures.map(c => String(c?.job_id || '').toLowerCase()).filter(id => /^[0-9a-f-]{36}$/i.test(id)));
return ids.size === expectedCount;
} Try / catch
try {
const ids = await submittedJobIdsFromCaptures(page, captures, expected);
} catch (err) {
const m = err.message.match(/expected (\d+) new job\(s\), received (\d+)/);
if (m) console.error(`Ambiguous submit: ${m[2]}/${m[1]} jobs confirmed — resubmit the missing ${m[1] - m[2]}`);
else throw err;
} Prevention
- Keep batch sizes small so partial failures are rare
- Record submitted job ids to reconcile expected vs received
- Avoid including current-batch ids in baselineIds
- Monitor Midjourney API response shapes in CI
When it happens
Trigger: captures contain at least one success row or at least one valid UUID, but the count of unique UUIDs passing UUID_RE and not in baselineIds does not equal expectedCount. Typically a partial submit: some rows succeeded, some failed silently or returned unparseable job ids.
Common situations: Batch submits where Midjourney throttled part of the request, failure rows present but also some successes (so 2630 does not fire), or responses missing expected job_id fields due to an API response-shape change.
Related errors
- --repeat must be a positive integer
- operation must be one of: ${ACTION_CHOICES.join(', ')}
- --kind must be one of: ${KINDS.join(', ')}
- Image jobs only support --kind image
- Midjourney generation
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/108b92b9f03df1b2.
Report an issue: GitHub.