jackwener/OpenCLI · error · ArgumentError

medium limit must be <= ${maxValue}

Error message

medium limit must be <= ${maxValue}

What it means

requireBoundedInt enforces an upper bound on the medium tag --limit option after validating positivity. When the supplied integer exceeds the maxValue configured for the command, ArgumentError is thrown with the exact limit so the user knows the ceiling.

Source

Thrown at clis/medium/tag.js:72

        throw new ArgumentError('medium tag is required (e.g. "programming", "javascript")');
    }
    if (!TAG_PATTERN.test(s)) {
        throw new ArgumentError(
            `medium tag "${value}" is not valid`,
            'Tags are lowercase alphanumeric, optionally hyphenated (e.g. "machine-learning").',
        );
    }
    return s;
}

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

cli({
    site: 'medium',
    name: 'tag',
    access: 'read',
    description: 'Latest Medium articles tagged with a given keyword (RSS feed)',
    domain: 'medium.com',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'tag', positional: true, required: true, help: 'Lowercase tag slug (e.g. "programming", "machine-learning")' },
        { name: 'limit', type: 'int', default: 20, help: 'Max articles (1-25 — single RSS page)' },
    ],
    columns: ['rank', 'title', 'author', 'description', 'categories', 'published', 'url'],
    func: async (args) => {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lower the --limit value to at most the maxValue shown in the error message.
  2. Fetch in multiple bounded calls if you need more items than one request allows.
  3. Inspect cli() at the bottom of clis/medium/tag.js to see the supported max for the limit flag.
  4. If the cap is genuinely too low for your use case, request a higher default in an upstream issue.

Example fix

// before
medium tag programming --limit 1000
// after (assuming max 50)
medium tag programming --limit 50
Defensive patterns

Strategy: validation

Validate before calling

const MAX_LIMIT = 50; // check cli() in clis/medium/tag.js for the real cap
const n = Number(limit);
if (!Number.isInteger(n) || n <= 0 || n > MAX_LIMIT) {
  throw new Error(`--limit must be a positive integer <= ${MAX_LIMIT}`);
}

Type guard

function isBoundedInt(v, max) {
  return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max;
}

Try / catch

try {
  await run(['medium', 'tag', tag, '--limit', String(limit)]);
} catch (e) {
  const m = /limit must be <= (\d+)/.exec(e.message);
  if (m) {
    console.error(`Clamping limit ${limit} to ${m[1]}`);
    await run(['medium', 'tag', tag, '--limit', m[1]]);
  } else throw e;
}

Prevention

When it happens

Trigger: Running `medium tag <tag> --limit <n>` where n is a positive integer but greater than the command's configured maxValue (e.g. asking for hundreds of posts when the adapter caps the limit).

Common situations: Users expecting unlimited pagination via a huge limit; copying limits from other CLIs with higher caps; scripts computing counts (e.g. full feed size) and passing them straight through.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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