jackwener/OpenCLI · error · ArgumentError

${label} must be a positive integer

Error message

${label} must be a positive integer

What it means

requirePositiveInt coerces its input with Number() and requires an integer >= 1, throwing ArgumentError with the given label otherwise. It backs the `--timeout` and `--limit` options, so any non-integer, NaN, or <1 value fails fast before any Suno request.

Source

Thrown at clis/suno/utils.js:88

export function normalizeBooleanFlag(value, fallback = false) {
    if (typeof value === 'boolean') return value;
    if (value === null || value === undefined || value === '') return fallback;
    const s = String(value).trim().toLowerCase();
    return s === 'true' || s === '1' || s === 'yes' || s === 'on';
}

export function unwrapEvaluateResult(value) {
    if (value && typeof value === 'object' && 'session' in value && 'data' in value) {
        return value.data;
    }
    return value;
}

export function requirePositiveInt(value, label) {
    const n = Number(value);
    if (!Number.isInteger(n) || n < 1) {
        throw new ArgumentError(`${label} must be a positive integer`);
    }
    return n;
}

export function requireNonNegativeInt(value, label) {
    const n = Number(value);
    if (!Number.isInteger(n) || n < 0) {
        throw new ArgumentError(`${label} must be a non-negative integer`);
    }
    return n;
}

export function clampSlider(value, label, def) {
    if (value === undefined || value === null || value === '') return def;
    const n = Number(value);
    if (!Number.isFinite(n) || n < 0 || n > 1) {
        throw new ArgumentError(`${label} must be a number between 0 and 1`);
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a whole number >= 1, e.g. `--timeout 30 --limit 10`.
  2. Strip units from the value (`30s` → `30`).
  3. Check the label in the message to see which flag is offending.
  4. Quote the value in your shell if it contains characters that break argument parsing.

Example fix

// before
opencli suno list --limit 0
// after
opencli suno list --limit 10
Defensive patterns

Strategy: validation

Validate before calling

function isPositiveInt(v) { const n = Number(v); return Number.isInteger(n) && n >= 1; }
if (!isPositiveInt(limit)) throw new Error('--limit must be a positive integer');

Type guard

function isPositiveInt(v) {
  const n = Number(v);
  return Number.isFinite(n) && Number.isInteger(n) && n >= 1;
}

Try / catch

try {
  await run({ limit: requirePositiveInt(rawLimit, 'limit') });
} catch (err) {
  if (err.name === 'ArgumentError' && /must be a positive integer/.test(err.message)) {
    limit = 10; // sensible default
  } else throw err;
}

Prevention

When it happens

Trigger: Passing `--timeout 0`, `--limit -5`, `--timeout abc`, `--limit 2.5`, or an empty-string value that coerces to NaN/0 for any option routed through requirePositiveInt (timeout, limit).

Common situations: Typing fractional or zero values; shell quoting issues producing empty strings; copying examples with units like `--timeout 30s` (coerces to NaN); using negative numbers intending 'unlimited'.

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