{"record":{"id":"88daef17f95aabc7","repo":"jackwener/OpenCLI","slug":"goproxy-label-must-be-maxvalue","errorCode":null,"errorMessage":"goproxy ${label} must be <= ${maxValue}","messagePattern":"goproxy (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/goproxy/utils.js","lineNumber":55,"sourceCode":"    const s = String(value ?? '').trim();\n    if (!s) throw new ArgumentError('goproxy --version cannot be empty');\n    if (!VERSION_TAG.test(s)) {\n        throw new ArgumentError(\n            `goproxy --version \"${value}\" is not a valid Go semver tag`,\n            'Use the GOPROXY canonical form like \"v1.2.3\" or \"v0.0.0-20240101010101-abcdef012345\".',\n        );\n    }\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(`goproxy ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`goproxy ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nasync function rawFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that proxy.golang.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404 || resp.status === 410) {\n        throw new EmptyResultError(label, `proxy.golang.org returned ${resp.status} for ${url}.`);\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/goproxy/utils.js#L37-L73","documentation":"Thrown by requireBoundedInt at clis/goproxy/utils.js:55 when the value is a positive integer but exceeds maxValue, the per-option upper cap set by the calling command. The cap protects proxy.golang.org (and your shell) from unbounded result sizes.","triggerScenarios":"Requesting e.g. --limit 5000 when the command's maxValue is 100; a config file with an oversized page size; computing a limit from counts that can exceed the cap.","commonSituations":"Trying to 'download everything in one request'; raising limits in config after a tool update changed the ceiling; passing a total item count as a limit.","solutions":["Lower the value to ≤ the cap shown in the message (`must be <= ${maxValue}`) — e.g. --limit 100.","If you need more results, page through requests instead of one oversized limit.","Check `goproxy --help` for the documented maximum for each numeric option.","Clamp in code: Math.min(value, maxValue) before calling."],"exampleFix":"// before\nlimit(userInput);               // userInput = 5000\n// after\nlimit(Math.min(userInput, 100));","handlingStrategy":"validation","validationCode":"const MAX_LIMIT = 100;\nfunction clampLimit(v, max = MAX_LIMIT) {\n  const n = Number(v);\n  if (!Number.isInteger(n) || n <= 0) throw new Error('limit must be a positive integer');\n  if (n > max) throw new Error(`limit must be <= ${max}`);\n  return n;\n}\nclampLimit(rawInput);","typeGuard":"const withinBound = (v, max) =>\n  typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max;","tryCatchPattern":"try {\n  const n = limit(rawInput, defaultVal, MAX);\n} catch (err) {\n  if (err instanceof ArgumentError && /must be <=/.test(err.message)) {\n    console.error(`Lower --limit to ≤ ${MAX}; page through results for more.`);\n  } else throw err;\n}","preventionTips":["Clamp user input with Math.min(value, maxValue) before invoking the API.","Document the per-command maximum in help text and config schemas.","Page requests instead of requesting oversized single batches."],"tags":["argument-error","input-validation","goproxy","bounds-check"],"backgroundTag":"argument-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}