jackwener/OpenCLI · error · ArgumentError

${label} must contain one or more non-empty strings

Error message

${label} must contain one or more non-empty strings

What it means

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.

Source

Thrown at clis/midjourney/utils.js:876

    : null;
  return { avgDailyMinutes, projectedExhaustionDate: projected };
}

export function parseReferenceArgument(value, label, { multiple = true, allowStyleCode = false } = {}) {
  if (value == null || value === '') return [];
  let items;
  const raw = String(value).trim();
  if (raw.startsWith('[')) {
    try {
      items = JSON.parse(raw);
    } catch (error) {
      throw new ArgumentError(`${label} must be a path/URL or a JSON array: ${errorMessage(error)}`);
    }
  } else {
    items = [raw];
  }
  if (!Array.isArray(items) || items.length === 0 || items.some((item) => typeof item !== 'string' || !item.trim())) {
    throw new ArgumentError(`${label} must contain one or more non-empty strings`);
  }
  if (!multiple && items.length !== 1) throw new ArgumentError(`${label} accepts exactly one reference`);
  return items.map((item) => item.trim()).map((item) => {
    if (allowStyleCode && /^\d+$/.test(item)) return { kind: 'styleCode', value: item };
    if (/^https:\/\//i.test(item)) {
      try {
        const parsed = new URL(item);
        const match = parsed.hostname === MIDJOURNEY_DOMAIN
          ? parsed.pathname.match(/^\/jobs\/([0-9a-f-]{36})\/?$/i)
          : null;
        if (match && UUID_RE.test(match[1])) {
          const index = Number(parsed.searchParams.get('index') || 0);
          if (!Number.isInteger(index) || index < 0 || index > 3) {
            throw new ArgumentError(`${label} Midjourney job URL index must be 0..3: ${item}`);
          }
          return { kind: 'url', value: originalImageUrl(match[1].toLowerCase(), index), source: item };
        }
      } catch (error) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass one or more actual non-empty strings: file paths, https:// URLs, or Midjourney job URLs
  2. For multiple references pass a JSON array of strings, e.g. '["img1.png","img2.png"]'
  3. Check shell quoting/variable expansion so the flag value is never empty
  4. Trim values: whitespace-only entries are rejected like empty ones

Example fix

// before
clis/midjourney --refs '[]'
clis/midjourney --refs "$UNSET_VAR"
// after
clis/midjourney --refs '["./cat.png","./dog.png"]'
Defensive patterns

Strategy: validation

Validate before calling

function validateRefInput(raw) {
  const items = Array.isArray(raw) ? raw : [raw];
  if (items.length === 0 || items.some(i => typeof i !== 'string' || !i.trim())) {
    throw new Error('refs must contain one or more non-empty strings');
  }
}

Type guard

const isValidRefs = (v) => Array.isArray(v) && v.length > 0 && v.every((i) => typeof i === 'string' && i.trim().length > 0);

Try / catch

try {
  const refs = parseReferences('refs', raw, { multiple: true });
} catch (e) {
  if (e instanceof ArgumentError) console.error('Bad --refs input:', e.message);
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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