{"record":{"id":"7c742a7127b90112","repo":"jackwener/OpenCLI","slug":"dockerhub-label-must-be-a-positive-integer","errorCode":null,"errorMessage":"dockerhub ${label} must be a positive integer","messagePattern":"dockerhub (.+?) must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/dockerhub/utils.js","lineNumber":26,"sourceCode":"\nexport const HUB_BASE = 'https://hub.docker.com/v2';\nconst UA = 'opencli-dockerhub-adapter (+https://github.com/jackwener/opencli)';\n\n// Docker Hub repository slugs are 2-255 chars, lowercase alphanumerics + `_.-`,\n// optionally prefixed with a Docker Hub user/org of the same charset.\nconst SLUG = /^[a-z0-9][a-z0-9._-]*$/;\n\nexport function requireString(value, label) {\n    const s = String(value ?? '').trim();\n    if (!s) throw new ArgumentError(`dockerhub ${label} cannot be empty`);\n    return s;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    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('/');","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/dockerhub/utils.js#L8-L44","documentation":"requireBoundedInt validates that a labeled numeric argument is a positive integer within a max bound. This ArgumentError is thrown when the value is not an integer or is <= 0 (default label 'limit'). Docker Hub page_size requires a positive integer.","triggerScenarios":"Passing --limit 0, a negative number, a non-numeric string like 'all', a float like 2.5, or a value that Number() coerces to NaN/Infinity.","commonSituations":"Setting limit from a config file where it's an empty string; typos like '--limit 2five'; users expecting limit=0 to mean 'unlimited'.","solutions":["Pass a positive integer, e.g. --limit 25","Keep the value <= the command's max (100 for search)","Fix the config/script value producing a non-numeric limit","Omit the flag to use the default (25)"],"exampleFix":"// before\ndockerhub search --query nginx --limit 0\n// after\ndockerhub search --query nginx --limit 25","handlingStrategy":"validation","validationCode":"const n = Number(args.limit ?? 25); if (!Number.isInteger(n) || n <= 0) throw new Error(`--limit must be a positive integer, got ${args.limit}`);","typeGuard":"function isPositiveInt(v) { return typeof v === 'number' && Number.isInteger(v) && v > 0; }","tryCatchPattern":"try { await search(args); } catch (e) { if (e instanceof ArgumentError && /must be a positive integer/.test(e.message)) { args.limit = 25; /* retry with default */ } else throw e; }","preventionTips":["Pass explicit positive-integer limits","Never use 0 or negative values expecting 'unlimited'","Coerce config values with Number() and validate before use"],"tags":["argument-validation","numeric","dockerhub"],"backgroundTag":"invalid-parameter-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}