{"record":{"id":"e87719c3f91c6e68","repo":"jackwener/OpenCLI","slug":"dockerhub-image-name-is-required-e-g-nginx-l","errorCode":null,"errorMessage":"dockerhub image name is required (e.g. \"nginx\", \"library/nginx\", \"bitnami/redis\")","messagePattern":"dockerhub image name is required \\(e\\.g\\. \"nginx\", \"library/nginx\", \"bitnami/redis\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/dockerhub/utils.js","lineNumber":42,"sourceCode":"    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`dockerhub ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`dockerhub ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\n/**\n * Split an image identifier into `{owner, name}`. Bare names use the implicit\n * `library` owner that Docker Hub uses for official images (`nginx` →\n * `library/nginx`).\n */\nexport function parseImage(input) {\n    const raw = String(input ?? '').trim().toLowerCase();\n    if (!raw) {\n        throw new ArgumentError('dockerhub image name is required (e.g. \"nginx\", \"library/nginx\", \"bitnami/redis\")');\n    }\n    const slash = raw.indexOf('/');\n    let owner;\n    let name;\n    if (slash >= 0) {\n        owner = raw.slice(0, slash);\n        name = raw.slice(slash + 1);\n    }\n    else {\n        owner = 'library';\n        name = raw;\n    }\n    if (!SLUG.test(owner) || !SLUG.test(name)) {\n        throw new ArgumentError(\n            `dockerhub image \"${input}\" is not a valid repository slug`,\n            'Use lowercase letters / digits / \"._-\", optionally prefixed with \"<owner>/\".',\n        );\n    }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/dockerhub/utils.js#L24-L60","documentation":"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.","triggerScenarios":"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.","commonSituations":"Scripts where the image name variable is empty; forgetting the positional/flag argument; pipeline configs with a placeholder image field never filled in.","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"],"exampleFix":"// before\ndockerhub info --image \"$IMG\"   # IMG unset\n// after\n: \"${IMG:?IMG required}\" && dockerhub info --image \"$IMG\"","handlingStrategy":"validation","validationCode":"const img = (args.image ?? '').trim(); if (!img) throw new Error('--image is required, e.g. nginx or bitnami/redis');","typeGuard":"function hasImageArg(a) { return typeof a?.image === 'string' && a.image.trim() !== ''; }","tryCatchPattern":"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; }","preventionTips":["Always supply the image argument for image commands","Validate variables feeding --image are non-empty","Use owner/name form for non-official images"],"tags":["argument-validation","image-parsing","dockerhub"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}