jackwener/OpenCLI · error · ArgumentError

dockerhub image "${input}" is not a valid repository slug. U

Error message

dockerhub image "${input}" is not a valid repository slug. Use lowercase letters / digits / "._-", optionally prefixed with "<owner>/".

What it means

parseImage validates each slug segment against /​^[a-z0-9][a-z0-9._-]*$/ and throws this ArgumentError if the owner or name contains invalid characters (uppercase, spaces, tags like ':latest', registry prefixes, etc.).

Source

Thrown at clis/dockerhub/utils.js:56

 */
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) {
        owner = raw.slice(0, slash);
        name = raw.slice(slash + 1);
    }
    else {
        owner = 'library';
        name = raw;
    }
    if (!SLUG.test(owner) || !SLUG.test(name)) {
        throw new ArgumentError(
            `dockerhub image "${input}" is not a valid repository slug`,
            'Use lowercase letters / digits / "._-", optionally prefixed with "<owner>/".',
        );
    }
    if (name.length < 2 || name.length > 255) {
        throw new ArgumentError(
            `dockerhub image "${input}" name must be 2-255 chars`,
        );
    }
    return { owner, name };
}

export async function hubFetch(url, label) {
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
    }
    catch (err) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lowercase the name and drop the tag/digest: 'nginx:1.25' -> 'nginx'
  2. Remove registry prefixes: 'docker.io/library/nginx' -> 'library/nginx'
  3. Keep only [a-z0-9._-] characters, optionally with '<owner>/' prefix
  4. Normalize input in your script before calling the CLI

Example fix

// before
dockerhub info --image 'NGINX:latest'
// after
dockerhub info --image 'nginx'
Defensive patterns

Strategy: validation

Validate before calling

const SLUG = /^[a-z0-9][a-z0-9._-]*$/; const raw = args.image.trim().toLowerCase().replace(/^docker\.io\//,'').split(':')[0]; const [owner, name = 'library'] = raw.includes('/') ? raw.split('/') : ['library', raw]; if (!SLUG.test(owner) || !SLUG.test(name)) throw new Error(`invalid slug: ${args.image}`);

Type guard

function isValidSlug(s) { return typeof s === 'string' && /^[a-z0-9][a-z0-9._-]*$/.test(s); }

Try / catch

try { await info(args); } catch (e) { if (e instanceof ArgumentError && e.message.includes('not a valid repository slug')) { console.error('Normalize the image ref: lowercase, no tag, no registry prefix'); process.exitCode = 2; } else throw e; }

Prevention

When it happens

Trigger: Passing 'NGINX' (uppercase), 'my image', 'nginx:1.25' (tag included), 'docker.io/library/nginx' (registry prefix), or 'nginx/' with an empty segment.

Common situations: Pasting a full image reference including registry host or tag; users typing image names with capitals; stripping owner but leaving the slash.

Related errors


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