jackwener/OpenCLI · error · EmptyResultError

Job ${jobId} was not found in the current account.

Error message

Job ${jobId} was not found in the current account.

What it means

fetchJobStatus looks up a single job by ID within the array returned by fetchJobStatuses. If no row with a matching id exists and allowMissing is false, it throws EmptyResultError for the 'midjourney status' query. This signals the job ID is not present under the currently authenticated account rather than a network failure.

Source

Thrown at clis/midjourney/utils.js:352

export async function fetchJobStatuses(page, jobIds) {
  if (!Array.isArray(jobIds) || !jobIds.length) return [];
  const payload = await midjourneyJson(page, '/api/job-status', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: { jobIds, _frontend_source: 'opencli_adapter' },
  });
  if (!Array.isArray(payload)) {
    throw new CommandExecutionError('Midjourney job-status endpoint returned a malformed payload');
  }
  return payload;
}

export async function fetchJobStatus(page, jobId, { allowMissing = false } = {}) {
  const payload = await fetchJobStatuses(page, [jobId]);
  const job = payload.find((row) => row?.id === jobId) || null;
  if (!job && !allowMissing) {
    throw new EmptyResultError('midjourney status', `Job ${jobId} was not found in the current account.`);
  }
  return job;
}

export async function cancelMidjourneyJob(page, jobId) {
  let result;
  try {
    result = unwrapEvaluateResult(await page.evaluate(async (id) => {
      const response = await fetch('/api/job-cancel', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', 'X-CSRF-Protection': '1' },
        body: JSON.stringify({ job_id: id }),
      });
      return { ok: response.ok, status: response.status, body: await response.text() };
    }, jobId));
  } catch (error) {
    throw new CommandExecutionError(`Midjourney cancel request failed: ${errorMessage(error)}`);
  }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run the midjourney status/list command to confirm the job ID exists in the current account and copy it exactly.
  2. Verify you are logged into the same Midjourney account that created the job.
  3. Pass allowMissing: true if your flow tolerates absent jobs and handle the null return yourself.
  4. Re-check the job URL on midjourney.com — if the web UI cannot find it, the job no longer exists.

Example fix

// before
const job = await fetchJobStatus(page, jobId); // throws when absent
// after
const job = await fetchJobStatus(page, jobId, { allowMissing: true });
if (!job) console.warn(`Job ${jobId} not found; it may have expired or belong to another account.`);
Defensive patterns

Strategy: validation

Validate before calling

// validate the job ID format before lookup
if (!/^[0-9a-f-]{10,}$/i.test(jobId)) throw new Error(`Invalid Midjourney job ID: ${jobId}`);
// optionally confirm existence with allowMissing first
const probe = await fetchJobStatus(page, jobId, { allowMissing: true });
if (!probe) throw new Error(`Job ${jobId} not found in this account; check the ID or account.`);

Type guard

function isKnownJob(payload, jobId) {
  return Array.isArray(payload) && payload.some((row) => row?.id === jobId);
}

Try / catch

try {
  const job = await fetchJobStatus(page, jobId);
} catch (e) {
  if (e.name === 'EmptyResultError' || String(e.message).includes('was not found')) {
    console.error(`Job ${jobId} does not exist in the current account; list jobs to get valid IDs.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling fetchJobStatus (or waitForCompletedJob, statuses source/job flows) with a jobId that does not exist for the logged-in Midjourney account, a typo'd or truncated job ID, or a job that has aged out / been deleted from the account history.

Common situations: Copying a job ID from a different Midjourney account or workspace; referencing a job whose history was purged (old jobs expire); casing mistakes since IDs are compared exactly against row?.id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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