jackwener/OpenCLI · error · ArgumentError

upwork ${label} must be <= ${max}

Error message

upwork ${label} must be <= ${max}

What it means

The upper-bound branch of requireBoundedInt: throws ArgumentError when the integer option exceeds the allowed maximum. Prevents absurdly large limits/pages from being sent to Upwork or blowing up row mapping.

Source

Thrown at clis/upwork/utils.js:68

export function requireQuery(value, label = 'query') {
    const q = String(value ?? '').trim();
    if (!q) throw new ArgumentError(`upwork ${label} cannot be empty`);
    return q;
}

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

export function requireBoundedInt(value, defaultValue, min, max, label) {
    const n = requirePositiveInt(value, defaultValue, label);
    if (n < min) throw new ArgumentError(`upwork ${label} must be >= ${min}`);
    if (n > max) throw new ArgumentError(`upwork ${label} must be <= ${max}`);
    return n;
}

/**
 * Upwork job ids are the ciphertext form starting with `~01` or `~02`
 * (the encoded uid surfaced everywhere in URLs and search results).
 * Accepts a bare ciphertext or a full `/jobs/~02…` URL.
 */
export function requireCiphertext(value) {
    let id = String(value ?? '').trim();
    if (!id) throw new ArgumentError('upwork job id is required');
    const urlMatch = id.match(/~0[12]\d+/);
    if (urlMatch) id = urlMatch[0];
    if (!CIPHERTEXT_PATTERN.test(id)) {
        throw new ArgumentError(`upwork job id "${value}" is not a valid ciphertext (expected ~01… or ~02… followed by digits)`);
    }
    return id;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lower the option value to at most the maximum shown in the message
  2. Use pagination (page option) instead of a giant limit to fetch more results
  3. Omit the option to use the built-in default

Example fix

// before
$ opencli upwork search "vue" --limit 500
// error: upwork limit must be <= 100
// after
$ opencli upwork search "vue" --limit 100
// then paginate: --page 2
Defensive patterns

Strategy: validation

Validate before calling

const n = Number(limit);
if (!Number.isInteger(n) || n > max) throw new RangeError(`limit must be <= ${max}`);

Type guard

function isBoundedInt(v, min, max) {
  return Number.isInteger(v) && v >= min && v <= max;
}

Try / catch

try {
  return await cmd({ limit });
} catch (e) {
  if (e instanceof ArgumentError && /must be <=/.test(e.message)) {
    return cmd({ limit: MAX_LIMIT });
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing an option like `limit` with a value greater than `max` (e.g. --limit 1000 when max is 100); a script or alias supplying an unbounded count value.

Common situations: Automations that request 'all results' by setting a huge limit; users assuming limits are unlimited; defaults migrated from another adapter with looser caps.

Related errors


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