jackwener/OpenCLI · error · ArgumentError

${label} must be <= ${maxValue}

Error message

${label} must be <= ${maxValue}

What it means

parseLimit throws this ArgumentError when the requested limit exceeds the maximum allowed (default 100). Atlassian's REST APIs cap page sizes; requesting more would either fail upstream or be truncated, so the CLI enforces the bound locally.

Source

Thrown at clis/_atlassian/shared.js:281

    }
    const s = String(value).trim();
    if (!s) throw new CommandExecutionError(`${label} did not include a stable ${field}.`);
    return s;
}

export function requireNonEmptyRows(rows, label, hint) {
    if (!rows.length) throw new EmptyResultError(label, hint);
    return rows;
}

export function parseLimit(value, defaultValue = 20, maxValue = 100, label = 'limit') {
    const raw = value ?? defaultValue;
    const n = typeof raw === 'number' ? raw : Number(raw);
    if (!Number.isInteger(n) || n <= 0) {
        throw new ArgumentError(`${label} must be a positive integer`);
    }
    if (n > maxValue) {
        throw new ArgumentError(`${label} must be <= ${maxValue}`);
    }
    return n;
}

export function requireExecute(args, commandName) {
    if (args.execute !== true) {
        throw new ArgumentError(`${commandName} requires --execute to perform a remote write`);
    }
}

export async function readUtf8File(filePath) {
    const path = requireString(filePath, '--file');
    let fileStat;
    try {
        fileStat = await stat(path);
    } catch {
        throw new ArgumentError(`File not found: ${path}`);
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lower the limit to <= 100 (the default maximum).
  2. Paginate: loop requests with limit=100 and a cursor/next token until all rows are fetched.
  3. If you need the full dataset, use the CLI's export/bulk command if available, or aggregate paginated calls.
  4. Clamp the value in scripts: const n = Math.min(requested, 100).

Example fix

// before
opencli confluence list --space DEV --limit 500
// after — paginate
let start = 0;
while (true) {
  const rows = await run(['confluence', 'list', '--space', 'DEV', '--limit', '100', '--offset', String(start)]);
  all.push(...rows); if (rows.length < 100) break; start += 100;
}
Defensive patterns

Strategy: validation

Validate before calling

const MAX_LIMIT = 100;
function clampLimit(v, def = 20) {
  const n = parseLimitSafe(v, def);
  if (n > MAX_LIMIT) return MAX_LIMIT;
  return n;
}

Type guard

function isWithinLimit(n, max = 100) { return Number.isInteger(n) && n > 0 && n <= max; }

Try / catch

try {
  await listCmd({ limit: requested });
} catch (e) {
  if (/must be <=/.test(e.message)) {
    console.error(`Requested limit ${requested} exceeds the API cap — clamping to 100 and paginating.`);
    await paginate(requested);
  } else throw e;
}

Prevention

When it happens

Trigger: Passing --limit 500 or --limit 1000 to a list/search command whose maxValue is 100; scripts that set large page sizes to 'fetch everything'.

Common situations: Trying to export all pages in one call; copying a limit from another tool with a higher cap; hardcoded defaults from older scripts before the cap existed.

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/07a4ac2fbfd705c4. Report an issue: GitHub.