{"record":{"id":"0a40bfcc61e8e7be","repo":"jackwener/OpenCLI","slug":"kind-must-be-one-of-kinds-join","errorCode":null,"errorMessage":"--kind must be one of: ${KINDS.join(', ')}","messagePattern":"--kind must be one of: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/download.js","lineNumber":47,"sourceCode":"  defaultFormat: 'plain',\n  args: [\n    { name: 'job', positional: true, required: true, help: 'Job UUID or Midjourney /jobs/<uuid> URL' },\n    { name: 'index', default: 'all', help: 'Candidate 1..4 or all' },\n    { name: 'kind', default: 'auto', help: 'auto, image, video-raw, video-social, or gif' },\n    { name: 'output', default: '~/Pictures/Midjourney', help: 'Output directory' },\n    { name: 'force', type: 'boolean', default: false, help: 'Overwrite existing non-empty files' },\n  ],\n  columns: ['job_id', 'status', 'kind', 'index', 'file', 'bytes', 'mime', 'url'],\n  func: async (page, kwargs) => {\n    const jobId = parseJobId(kwargs.job);\n    const job = await fetchJobStatus(page, jobId);\n    const status = String(job.current_status || job.status || '').toLowerCase();\n    if (status !== 'completed') {\n      throw new CommandExecutionError(`Midjourney job ${jobId} is \"${status || 'missing'}\"; media is available after completion.`);\n    }\n    const video = isVideoJob(job);\n    let kind = String(kwargs.kind || 'auto').trim().toLowerCase();\n    if (!KINDS.includes(kind)) throw new ArgumentError(`--kind must be one of: ${KINDS.join(', ')}`);\n    if (kind === 'auto') kind = video ? 'video-raw' : 'image';\n    if (video && kind === 'image') throw new ArgumentError('Video jobs support video-raw, video-social, or gif downloads');\n    if (!video && kind !== 'image') throw new ArgumentError('Image jobs only support --kind image');\n\n    const indices = parseImageIndices(kwargs.index, Number(job.batch_size || (video ? 1 : 4)));\n    const outputDir = resolveOutputDir(kwargs.output);\n    const force = normalizeBoolean(kwargs.force);\n    let files;\n    if (kind === 'image') {\n      files = (await downloadOriginals(page, jobId, indices, outputDir, force)).map((item) => ({\n        ...item,\n        kind: 'image',\n      }));\n    } else if (kind === 'video-raw') {\n      files = [];\n      for (const index of indices) files.push(await downloadRawVideo(page, jobId, index, outputDir, force));\n    } else {\n      files = [];","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/download.js#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the valid kinds: auto, image, video-raw, video-social, gif (or omit --kind to use the default 'auto')","Check `opencli midjourney download --help` for the accepted --kind values","Fix typos in scripts/aliases (e.g. 'video' → 'video-raw', 'social' → 'video-social')","Let auto mode decide by removing --kind, which picks video-raw for video jobs and image for image jobs"],"exampleFix":"// before\nopencli midjourney download abc123 --kind video\n// after\nopencli midjourney download abc123 --kind video-raw","handlingStrategy":"validation","validationCode":"const KINDS = ['auto', 'image', 'video-raw', 'video-social', 'gif'];\nconst kind = String(kwargs.kind || 'auto').trim().toLowerCase();\nif (!KINDS.includes(kind)) {\n  throw new Error(`--kind must be one of: ${KINDS.join(', ')}`);\n}","typeGuard":"function isValidKind(kind) {\n  return ['auto', 'image', 'video-raw', 'video-social', 'gif'].includes(\n    String(kind || 'auto').trim().toLowerCase(),\n  );\n}","tryCatchPattern":"try {\n  await run('midjourney', 'download', jobId, ['--kind', kind]);\n} catch (err) {\n  if (err.message.startsWith('--kind must be one of')) {\n    // fall back to default 'auto' kind and retry\n  } else throw err;\n}","preventionTips":["Use the documented kinds: auto, image, video-raw, video-social, gif","Normalize user input with trim().toLowerCase() before passing --kind","Prefer omitting --kind (default 'auto') unless a specific variant is needed","Check --help output when scripting to confirm valid kind names"],"tags":["argument-validation","cli","midjourney"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}