jackwener/OpenCLI · error · ArgumentError

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

Error message

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

What it means

Thrown by requireBoundedInt at clis/goproxy/utils.js:55 when the value is a positive integer but exceeds maxValue, the per-option upper cap set by the calling command. The cap protects proxy.golang.org (and your shell) from unbounded result sizes.

Source

Thrown at clis/goproxy/utils.js:55

    const s = String(value ?? '').trim();
    if (!s) throw new ArgumentError('goproxy --version cannot be empty');
    if (!VERSION_TAG.test(s)) {
        throw new ArgumentError(
            `goproxy --version "${value}" is not a valid Go semver tag`,
            'Use the GOPROXY canonical form like "v1.2.3" or "v0.0.0-20240101010101-abcdef012345".',
        );
    }
    return s;
}

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

async function rawFetch(url, label) {
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that proxy.golang.org is reachable from this network.',
        );
    }
    if (resp.status === 404 || resp.status === 410) {
        throw new EmptyResultError(label, `proxy.golang.org returned ${resp.status} for ${url}.`);
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lower the value to ≤ the cap shown in the message (`must be <= ${maxValue}`) — e.g. --limit 100.
  2. If you need more results, page through requests instead of one oversized limit.
  3. Check `goproxy --help` for the documented maximum for each numeric option.
  4. Clamp in code: Math.min(value, maxValue) before calling.

Example fix

// before
limit(userInput);               // userInput = 5000
// after
limit(Math.min(userInput, 100));
Defensive patterns

Strategy: validation

Validate before calling

const MAX_LIMIT = 100;
function clampLimit(v, max = MAX_LIMIT) {
  const n = Number(v);
  if (!Number.isInteger(n) || n <= 0) throw new Error('limit must be a positive integer');
  if (n > max) throw new Error(`limit must be <= ${max}`);
  return n;
}
clampLimit(rawInput);

Type guard

const withinBound = (v, max) =>
  typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max;

Try / catch

try {
  const n = limit(rawInput, defaultVal, MAX);
} catch (err) {
  if (err instanceof ArgumentError && /must be <=/.test(err.message)) {
    console.error(`Lower --limit to ≤ ${MAX}; page through results for more.`);
  } else throw err;
}

Prevention

When it happens

Trigger: Requesting e.g. --limit 5000 when the command's maxValue is 100; a config file with an oversized page size; computing a limit from counts that can exceed the cap.

Common situations: Trying to 'download everything in one request'; raising limits in config after a tool update changed the ceiling; passing a total item count as a limit.

Related errors


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