{"record":{"id":"78bb0202abc385ee","repo":"jackwener/OpenCLI","slug":"nuget-label-must-be-maxvalue","errorCode":null,"errorMessage":"nuget ${label} must be <= ${maxValue}","messagePattern":"nuget (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/nuget/utils.js","lineNumber":31,"sourceCode":"// NuGet ID grammar (NuGet docs §package-id): up to 100 chars, alnum + `.` + `_` + `-`,\n// must start with letter/digit. Case-insensitive; we lowercase for the registration URL\n// because NuGet's CDN is case-sensitive on the path.\nconst PACKAGE_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,99})$/;\n\nexport function requireString(value, label) {\n    const s = String(value ?? '').trim();\n    if (!s) throw new ArgumentError(`nuget ${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(`nuget ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`nuget ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requirePackageId(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) throw new ArgumentError('nuget package id is required (e.g. \"Newtonsoft.Json\")');\n    if (!PACKAGE_ID_PATTERN.test(raw)) {\n        throw new ArgumentError(\n            `nuget package id \"${value}\" is not a valid NuGet identifier`,\n            'NuGet IDs are 1-100 chars: letters/digits/`.`/`_`/`-`, starting with letter or digit.',\n        );\n    }\n    return raw;\n}\n\nexport async function nugetFetch(url, label) {\n    let resp;","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/nuget/utils.js#L13-L49","documentation":"This ArgumentError is thrown by requireBoundedInt in clis/nuget/utils.js when the supplied value is a valid positive integer but exceeds the maxValue bound for that option. The library caps paging limits (e.g. limit) to what the NuGet API sensibly supports, and rejects anything above the cap with this message. The maxValue for each option is fixed by the calling adapter.","triggerScenarios":"Calling a nuget command with limit (or another labeled bounded option) set to a positive integer above the adapter's maximum, e.g. limit: 10000 when the cap is 100.","commonSituations":"Users asking for 'all results' via a huge page size; bulk scripts exporting the full package list in one call; misreading documentation about the maximum page size.","solutions":["Reduce the option value to at or below the max stated in the message, e.g. limit: 100","Page through results with multiple calls (offset/cursor) instead of one giant limit","Omit the option to use the safe default value"],"exampleFix":"// before\nawait nuget.limit(ctx, { limit: 5000 });\n// after\nawait nuget.limit(ctx, { limit: 100 }); // check the adapter's documented max","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 100; // check the adapter's documented max\nif (Number(opts.limit) > MAX_LIMIT) opts.limit = MAX_LIMIT;","typeGuard":"function isWithinMax(v, max) { const n = typeof v === 'number' ? v : Number(v); return Number.isInteger(n) && n > 0 && n <= max; }","tryCatchPattern":"try {\n  await nuget.limit(ctx, { limit });\n} catch (e) {\n  if (e instanceof ArgumentError && /must be <= (\\d+)/.test(e.message)) {\n    limit = Number(e.message.match(/must be <= (\\d+)/)[1]); // clamp to max and retry\n  } else throw e;\n}","preventionTips":["Clamp user-supplied limits to the documented maximum before calling","Paginate instead of requesting one huge page","Document the max in your own CLI's --help text","Read the max from the error message and auto-clamp"],"tags":["validation","arguments","limits","nuget"],"backgroundTag":"argument-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}