jackwener/OpenCLI · error · ArgumentError

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

Error message

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

What it means

requireBoundedInt throws this ArgumentError when the numeric argument is a valid positive integer but exceeds the allowed maximum (e.g. limit > 100 for dockerhub search). It caps request sizes to what the Docker Hub API accepts.

Source

Thrown at clis/dockerhub/utils.js:29

// Docker Hub repository slugs are 2-255 chars, lowercase alphanumerics + `_.-`,
// optionally prefixed with a Docker Hub user/org of the same charset.
const SLUG = /^[a-z0-9][a-z0-9._-]*$/;

export function requireString(value, label) {
    const s = String(value ?? '').trim();
    if (!s) throw new ArgumentError(`dockerhub ${label} cannot be empty`);
    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(`dockerhub ${label} must be a positive integer`);
    }
    if (n > maxValue) {
        throw new ArgumentError(`dockerhub ${label} must be <= ${maxValue}`);
    }
    return n;
}

/**
 * Split an image identifier into `{owner, name}`. Bare names use the implicit
 * `library` owner that Docker Hub uses for official images (`nginx` →
 * `library/nginx`).
 */
export function parseImage(input) {
    const raw = String(input ?? '').trim().toLowerCase();
    if (!raw) {
        throw new ArgumentError('dockerhub image name is required (e.g. "nginx", "library/nginx", "bitnami/redis")');
    }
    const slash = raw.indexOf('/');
    let owner;
    let name;
    if (slash >= 0) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reduce the limit to <= 100 (the search max)
  2. Paginate using subsequent pages if you need more results
  3. Clamp the value in your script: Math.min(limit, 100)

Example fix

// before
const limit = 500;
dockerhub search --query nginx --limit 500
// after
const limit = Math.min(500, 100);
dockerhub search --query nginx --limit 100 // paginate for more
Defensive patterns

Strategy: validation

Validate before calling

const n = Number(args.limit ?? 25); if (n > 100) throw new Error('--limit must be <= 100');

Type guard

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

Try / catch

try { await search(args); } catch (e) { if (e instanceof ArgumentError && e.message.includes('must be <=')) { args.limit = 100; /* clamp and retry */ } else throw e; }

Prevention

When it happens

Trigger: Calling dockerhub search with --limit 500 or any value > 100; a config default larger than the command's maxValue.

Common situations: Users wanting 'all' results set a huge limit; copying a limit from another tool with a higher cap; programmatically computing page size from a larger dataset.

Related errors


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