jackwener/OpenCLI · error · ArgumentError

--kind must be one of: ${KINDS.join(', ')}

Error message

--kind must be one of: ${KINDS.join(', ')}

What it means

This ArgumentError is thrown when the --kind option value is not one of the allowed KINDS: auto, image, video-raw, video-social, gif. The value is trimmed and lowercased before validation, so only genuinely unknown kinds fail.

Source

Thrown at clis/midjourney/download.js:47

  defaultFormat: 'plain',
  args: [
    { name: 'job', positional: true, required: true, help: 'Job UUID or Midjourney /jobs/<uuid> URL' },
    { name: 'index', default: 'all', help: 'Candidate 1..4 or all' },
    { name: 'kind', default: 'auto', help: 'auto, image, video-raw, video-social, or gif' },
    { name: 'output', default: '~/Pictures/Midjourney', help: 'Output directory' },
    { name: 'force', type: 'boolean', default: false, help: 'Overwrite existing non-empty files' },
  ],
  columns: ['job_id', 'status', 'kind', 'index', 'file', 'bytes', 'mime', 'url'],
  func: async (page, kwargs) => {
    const jobId = parseJobId(kwargs.job);
    const job = await fetchJobStatus(page, jobId);
    const status = String(job.current_status || job.status || '').toLowerCase();
    if (status !== 'completed') {
      throw new CommandExecutionError(`Midjourney job ${jobId} is "${status || 'missing'}"; media is available after completion.`);
    }
    const video = isVideoJob(job);
    let kind = String(kwargs.kind || 'auto').trim().toLowerCase();
    if (!KINDS.includes(kind)) throw new ArgumentError(`--kind must be one of: ${KINDS.join(', ')}`);
    if (kind === 'auto') kind = video ? 'video-raw' : 'image';
    if (video && kind === 'image') throw new ArgumentError('Video jobs support video-raw, video-social, or gif downloads');
    if (!video && kind !== 'image') throw new ArgumentError('Image jobs only support --kind image');

    const indices = parseImageIndices(kwargs.index, Number(job.batch_size || (video ? 1 : 4)));
    const outputDir = resolveOutputDir(kwargs.output);
    const force = normalizeBoolean(kwargs.force);
    let files;
    if (kind === 'image') {
      files = (await downloadOriginals(page, jobId, indices, outputDir, force)).map((item) => ({
        ...item,
        kind: 'image',
      }));
    } else if (kind === 'video-raw') {
      files = [];
      for (const index of indices) files.push(await downloadRawVideo(page, jobId, index, outputDir, force));
    } else {
      files = [];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use one of the valid kinds: auto, image, video-raw, video-social, gif (or omit --kind to use the default 'auto')
  2. Check `opencli midjourney download --help` for the accepted --kind values
  3. Fix typos in scripts/aliases (e.g. 'video' → 'video-raw', 'social' → 'video-social')
  4. Let auto mode decide by removing --kind, which picks video-raw for video jobs and image for image jobs

Example fix

// before
opencli midjourney download abc123 --kind video
// after
opencli midjourney download abc123 --kind video-raw
Defensive patterns

Strategy: validation

Validate before calling

const KINDS = ['auto', 'image', 'video-raw', 'video-social', 'gif'];
const kind = String(kwargs.kind || 'auto').trim().toLowerCase();
if (!KINDS.includes(kind)) {
  throw new Error(`--kind must be one of: ${KINDS.join(', ')}`);
}

Type guard

function isValidKind(kind) {
  return ['auto', 'image', 'video-raw', 'video-social', 'gif'].includes(
    String(kind || 'auto').trim().toLowerCase(),
  );
}

Try / catch

try {
  await run('midjourney', 'download', jobId, ['--kind', kind]);
} catch (err) {
  if (err.message.startsWith('--kind must be one of')) {
    // fall back to default 'auto' kind and retry
  } else throw err;
}

Prevention

When it happens

Trigger: Calling `opencli midjourney download <job> --kind <value>` where the trimmed/lowercased value is not in ['auto','image','video-raw','video-social','gif'] — e.g. --kind video, --kind mp4, --kind Image-with-caps mismatch beyond case, or an empty-but-present value that doesn't default.

Common situations: Guessing kind names like 'video' or 'png' instead of 'video-raw'/'image'; passing a kind copied from another CLI; scripting with a variable that is unset or misspelled; trailing whitespace or unicode lookalikes after trim/lowercase.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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