jackwener/OpenCLI · error · CommandExecutionError

Midjourney submission is ambiguous; ${ambiguousIds.length} n

Error message

Midjourney submission is ambiguous; ${ambiguousIds.length} new jobs matched the prompt

What it means

During submit-and-wait polling, the library tracks IDs of new jobs matching the submitted prompt. If more new jobs than expected match, the submission result is ambiguous and CommandExecutionError is thrown with the count and URLs of the ambiguous jobs. This prevents operating on the wrong job when the user (or a parallel session) submitted similar prompts concurrently.

Source

Thrown at clis/midjourney/utils.js:462

    });
    const matching = newRows.filter((row) => {
      const candidate = promptFromFullCommand(row.full_command);
      return candidate === expected || (
        expectedCore
        && promptCore(candidate) === expectedCore
        && promptKeySignature(candidate) === expectedSignature
      );
    });
    if (matching.length === expectedCount) {
      return [...matching]
        .sort((left, right) => Date.parse(left.enqueue_time) - Date.parse(right.enqueue_time))
        .map((row) => String(row.id).toLowerCase());
    }
    if (matching.length > expectedCount) ambiguousIds = matching.map((row) => String(row.id).toLowerCase());
    if (!(await waitForNextPoll(page, deadline, 1.5))) break;
  } while (true);
  if (ambiguousIds.length > expectedCount) {
    throw new CommandExecutionError(
      `Midjourney submission is ambiguous; ${ambiguousIds.length} new jobs matched the prompt`,
      ambiguousIds.map((id) => jobUrl(id)).join(', '),
    );
  }
  throw new TimeoutError(
    'Midjourney job submission',
    timeoutSeconds,
    `Expected ${expectedCount} uniquely matched job(s) after submission.`,
  );
}

export async function waitForDerivedJob(page, userId, parentJobId, baselineIds, timeoutSeconds, submittedAtMs) {
  const deadline = Date.now() + timeoutSeconds * 1000;
  let candidates = [];
  let consecutivePollFailures = 0;
  do {
    let recent;
    try {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the job URLs in the error, pick the intended one manually, and track/wait on that specific job ID instead of re-submitting.
  2. Use a more distinctive prompt text so matching is unique.
  3. Ensure no other session/process is submitting the same prompt concurrently.
  4. Rerun the command once the unrelated jobs finish, so only the new submission matches.
Defensive patterns

Strategy: validation

Validate before calling

// avoid duplicate submissions and generic prompts before running the submit flow
const recent = await fetchJobStatuses(page, recentJobIds).catch(() => []);
const inFlightSimilar = recent.filter((j) =>
  String(j.prompt || '').includes(promptCoreText) && !isTerminal(j)
);
if (inFlightSimilar.length > 0) {
  throw new Error(`${inFlightSimilar.length} similar job(s) already in flight; wait or track them by ID instead of resubmitting.`);
}

Try / catch

try {
  await submitAndAwait(page, prompt, { expectedCount: 1 });
} catch (e) {
  const m = String(e.message).match(/ambiguous; (\d+) new jobs/);
  if (m) {
    console.error('Pick the intended job from the URLs in the error and track it by ID instead of resubmitting.');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the submit flow when expectedCount new jobs matched the prompt within the polling window but matching.length exceeds expectedCount — e.g. duplicate submissions, a concurrent session sending the same /imagine prompt, or prompt text matching existing in-flight jobs.

Common situations: Double-submitting due to CLI retries without dedup; running two CLI sessions with the same prompt; using a very generic prompt that matches unrelated queued jobs within the 5s/poll matching window.

Related errors


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