{"record":{"id":"33e6776455be5556","repo":"jackwener/OpenCLI","slug":"maven-label-must-be-maxvalue","errorCode":null,"errorMessage":"maven ${label} must be <= ${maxValue}","messagePattern":"maven (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":29,"sourceCode":"\n// Maven groupId / artifactId tokens — Java-package-ish (letters / digits /\n// `_-.`), 1-200 chars; reverse-DNS dots are allowed in groupId.\nconst COORD_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\n\nexport function requireString(value, label) {\n    const s = String(value ?? '').trim();\n    if (!s) throw new ArgumentError(`maven ${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(`maven ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`maven ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\n/**\n * Parse a Maven coordinate `groupId:artifactId[:version]` into segments.\n * groupId / artifactId are required; version is optional.\n */\nexport function requireCoord(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) {\n        throw new ArgumentError('maven coordinate is required (e.g. \"com.fasterxml.jackson.core:jackson-databind\")');\n    }\n    const parts = raw.split(':');\n    if (parts.length < 2 || parts.length > 3) {\n        throw new ArgumentError(\n            `maven coordinate \"${value}\" must be \"groupId:artifactId\" or \"groupId:artifactId:version\"`,\n        );","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L11-L47","documentation":"`requireBoundedInt` enforces an upper bound and throws ArgumentError with `maven ${label} must be <= ${maxValue}` when the integer value exceeds it. For the `limit` argument the max is 200 (requireBoundedInt(args.limit, 30, 200)), so any limit > 200 is rejected.","triggerScenarios":"Calling an operation with `limit` set to an integer greater than the maxValue allowed, e.g. `limit: 500` or `limit: 1000` for maven search. Only reached after the value already passed the positive-integer check.","commonSituations":"'Fetch everything' attempts using an enormous limit; copying a max from a different API whose cap is higher (e.g. GitHub's 100 is fine here but 1000 is not); config shared across tools with different caps; not knowing the API's cap since it isn't in the error until you hit it.","solutions":["Reduce the limit to <= 200 for maven search","Paginate instead: issue multiple calls with limit 200 (or default 30) and aggregate results if you need more rows","Clamp the value in your own code before calling: Math.min(maxAllowed, requested)","Check the API/docs for the supported maximum rather than guessing"],"exampleFix":"// before\nawait mavenSearch({ query: 'jackson', limit: 1000 });\n// after\nconst docs = await mavenSearch({ query: 'jackson', limit: 200 }); // paginate for more","handlingStrategy":"validation","validationCode":"function clampLimit(v, dflt = 30, max = 200) {\n  if (v == null) return dflt;\n  const n = typeof v === 'number' ? v : Number(v);\n  return Math.min(max, Math.max(1, n));\n}","typeGuard":"function isIntWithin(v, max) { return Number.isInteger(v) && v > 0 && v <= max; }","tryCatchPattern":"try {\n  const docs = await mavenSearch({ query, limit });\n} catch (err) {\n  if (err instanceof ArgumentError && /must be <= /.test(err.message)) {\n    console.error('limit exceeds the API cap (200); paginate instead');\n    return;\n  }\n  throw err;\n}","preventionTips":["Clamp limits to the known maximum (200) before calling","Paginate with multiple calls rather than requesting one huge page","Don't reuse max values from other APIs' pagination schemes","Document/encode the cap in your own CLI validation"],"tags":["argument-error","maven","bounds-validation","input-validation"],"backgroundTag":"invalid-argument-type","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}