jackwener/OpenCLI · error · ArgumentError
dockerhub image name is required (e.g. "nginx", "library/ngi
Error message
dockerhub image name is required (e.g. "nginx", "library/nginx", "bitnami/redis")
What it means
parseImage splits an image identifier into owner/name for Docker Hub API calls and requires a non-empty input. This ArgumentError is thrown when the image argument is missing, null, or whitespace-only after trimming/lowercasing.
Source
Thrown at clis/dockerhub/utils.js:42
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) {
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>/".',
);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Provide the image name, e.g. --image nginx
- Use owner/name form for non-official images, e.g. --image bitnami/redis
- Ensure the variable feeding the flag is non-empty
Example fix
// before
dockerhub info --image "$IMG" # IMG unset
// after
: "${IMG:?IMG required}" && dockerhub info --image "$IMG" Defensive patterns
Strategy: validation
Validate before calling
const img = (args.image ?? '').trim(); if (!img) throw new Error('--image is required, e.g. nginx or bitnami/redis'); Type guard
function hasImageArg(a) { return typeof a?.image === 'string' && a.image.trim() !== ''; } Try / catch
try { await info(args); } catch (e) { if (e instanceof ArgumentError && e.message.includes('image name is required')) { console.error('Usage: --image <owner>/<name>'); process.exitCode = 2; } else throw e; } Prevention
- Always supply the image argument for image commands
- Validate variables feeding --image are non-empty
- Use owner/name form for non-official images
When it happens
Trigger: Calling a dockerhub command that takes an image (e.g. dockerhub tags/info) without the --image flag; passing an empty string; an unset variable expanding to nothing.
Common situations: Scripts where the image name variable is empty; forgetting the positional/flag argument; pipeline configs with a placeholder image field never filled in.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- dockerhub image "${input}" is not a valid repository slug. U
- dockerhub image "${input}" name must be 2-255 chars
- dockerhub ${label} cannot be empty
- dockerhub ${label} must be a positive integer
- dockerhub ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e87719c3f91c6e68.
Report an issue: GitHub.