jackwener/OpenCLI · error · ArgumentError

${label} cannot be empty

Error message

${label} cannot be empty

What it means

requireNonEmptyQuery rejects empty/whitespace-only query strings. Since it trims the value first, a string of spaces is also considered empty. It throws ArgumentError '<label> cannot be empty' to stop pointless remote searches.

Source

Thrown at clis/_shared/common.js:29

}
export function clampInt(raw, fallback, min, max) {
    const parsed = Number(raw);
    if (!Number.isFinite(parsed)) {
        return fallback;
    }
    return clamp(Math.floor(parsed), min, max);
}
export function normalizeNumericId(value, label, example) {
    const normalized = String(value ?? '').trim();
    if (!/^\d+$/.test(normalized)) {
        throw new ArgumentError(`${label} must be a numeric ID`, `Pass a numeric ${label}, for example: ${example}`);
    }
    return normalized;
}
export function requireNonEmptyQuery(value, label = 'query') {
    const normalized = String(value ?? '').trim();
    if (!normalized) {
        throw new ArgumentError(`${label} cannot be empty`);
    }
    return normalized;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a non-empty search/query value on the command line or in the config field.
  2. Check the shell variable feeding the flag: `${Q:-}` unset produces an empty argument — quote and default it or fail fast.
  3. Guard in scripts: `[ -n "$QUERY" ] || { echo 'query required'; exit 1; }` before invoking the CLI.

Example fix

// before
cli jira search --query "$QUERY"   # QUERY is empty
// after
[ -n "$QUERY" ] && cli jira search --query "$QUERY" || { echo 'QUERY is required'; exit 1; }
Defensive patterns

Strategy: validation

Validate before calling

const q = String(value ?? '').trim();
if (!q) throw new Error(`${label} is required and cannot be empty`);

Type guard

const isNonEmpty = (v) => typeof v === 'string' && v.trim().length > 0;

Try / catch

try {
  const q = requireNonEmptyQuery(raw, 'query');
} catch (err) {
  if (err.name === 'ArgumentError' && err.message.includes('cannot be empty')) {
    console.error('No query supplied: check the --query flag or the variable feeding it.');
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling requireNonEmptyQuery with '' , ' ', null, or undefined — typically a --query/--jql CLI option that was not supplied or was interpolated empty from a variable.

Common situations: Shell variable holding the query is unset/empty ($Q expands to nothing); config file field left blank; quoting bug that drops the argument entirely; search string composed of only whitespace after sanitization.

Related errors


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