{"record":{"id":"c2204220238eefb0","repo":"jackwener/OpenCLI","slug":"label-must-contain-one-or-more-non-empty-string","errorCode":null,"errorMessage":"${label} must contain one or more non-empty strings","messagePattern":"(.+?) must contain one or more non-empty strings","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":876,"sourceCode":"    : null;\n  return { avgDailyMinutes, projectedExhaustionDate: projected };\n}\n\nexport function parseReferenceArgument(value, label, { multiple = true, allowStyleCode = false } = {}) {\n  if (value == null || value === '') return [];\n  let items;\n  const raw = String(value).trim();\n  if (raw.startsWith('[')) {\n    try {\n      items = JSON.parse(raw);\n    } catch (error) {\n      throw new ArgumentError(`${label} must be a path/URL or a JSON array: ${errorMessage(error)}`);\n    }\n  } else {\n    items = [raw];\n  }\n  if (!Array.isArray(items) || items.length === 0 || items.some((item) => typeof item !== 'string' || !item.trim())) {\n    throw new ArgumentError(`${label} must contain one or more non-empty strings`);\n  }\n  if (!multiple && items.length !== 1) throw new ArgumentError(`${label} accepts exactly one reference`);\n  return items.map((item) => item.trim()).map((item) => {\n    if (allowStyleCode && /^\\d+$/.test(item)) return { kind: 'styleCode', value: item };\n    if (/^https:\\/\\//i.test(item)) {\n      try {\n        const parsed = new URL(item);\n        const match = parsed.hostname === MIDJOURNEY_DOMAIN\n          ? parsed.pathname.match(/^\\/jobs\\/([0-9a-f-]{36})\\/?$/i)\n          : null;\n        if (match && UUID_RE.test(match[1])) {\n          const index = Number(parsed.searchParams.get('index') || 0);\n          if (!Number.isInteger(index) || index < 0 || index > 3) {\n            throw new ArgumentError(`${label} Midjourney job URL index must be 0..3: ${item}`);\n          }\n          return { kind: 'url', value: originalImageUrl(match[1].toLowerCase(), index), source: item };\n        }\n      } catch (error) {","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L858-L894","documentation":"The reference parser turns a raw CLI value (a path/URL string or a JSON array of strings) into a normalized list of references, then asserts every entry is a non-empty string. This ArgumentError is thrown when the resolved list is empty, not an array, or contains blank/non-string entries, protecting the downstream reference-classification logic from unusable input.","triggerScenarios":"Passing an empty JSON array ('[]'), an empty or whitespace-only string, a JSON array containing numbers/objects/null instead of strings, or a value that parses into an empty item list.","commonSituations":"Shell variables that expand to empty (e.g. --refs \"$IMAGES\" where IMAGES is unset), build scripts interpolating missing values, users passing JSON numbers like [123] expecting style codes as integers, or quoting mistakes that yield \"\" as the whole argument.","solutions":["Pass one or more actual non-empty strings: file paths, https:// URLs, or Midjourney job URLs","For multiple references pass a JSON array of strings, e.g. '[\"img1.png\",\"img2.png\"]'","Check shell quoting/variable expansion so the flag value is never empty","Trim values: whitespace-only entries are rejected like empty ones"],"exampleFix":"// before\nclis/midjourney --refs '[]'\nclis/midjourney --refs \"$UNSET_VAR\"\n// after\nclis/midjourney --refs '[\"./cat.png\",\"./dog.png\"]'","handlingStrategy":"validation","validationCode":"function validateRefInput(raw) {\n  const items = Array.isArray(raw) ? raw : [raw];\n  if (items.length === 0 || items.some(i => typeof i !== 'string' || !i.trim())) {\n    throw new Error('refs must contain one or more non-empty strings');\n  }\n}","typeGuard":"const isValidRefs = (v) => Array.isArray(v) && v.length > 0 && v.every((i) => typeof i === 'string' && i.trim().length > 0);","tryCatchPattern":"try {\n  const refs = parseReferences('refs', raw, { multiple: true });\n} catch (e) {\n  if (e instanceof ArgumentError) console.error('Bad --refs input:', e.message);\n  throw e;\n}","preventionTips":["Always quote JSON arrays in the shell: --refs '[\"a.png\"]'","Check environment variables are set before interpolating into CLI flags","Validate inputs with the type guard before invoking the CLI","Remember whitespace-only strings count as empty"],"tags":["argument-validation","cli","input-validation"],"backgroundTag":"invalid-argument-input","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}