{"record":{"id":"dfa9e580804eb412","repo":"jackwener/OpenCLI","slug":"steam-label-must-be-maxvalue","errorCode":null,"errorMessage":"steam ${label} must be <= ${maxValue}","messagePattern":"steam (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/steam/utils.js","lineNumber":35,"sourceCode":"    const raw = value === undefined || value === null ? defaultValue : value;\n    const code = String(raw).trim().toLowerCase();\n    if (!/^[a-z]{2}$/.test(code)) {\n        throw new ArgumentError(\n            `steam currency must be a two-letter storefront country code (got \"${value}\")`,\n            'Examples: us, cn, jp, de. This controls Steam regional pricing and availability.',\n        );\n    }\n    return code;\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(`steam ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`steam ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireAppId(value) {\n    const s = String(value ?? '').trim();\n    if (!s) {\n        throw new ArgumentError('steam app id is required (e.g. \"620\" for Portal 2)');\n    }\n    if (!/^\\d+$/.test(s)) {\n        throw new ArgumentError(\n            `steam app id \"${value}\" must be a positive integer`,\n            'Copy the numeric id from `steam search` or the URL `store.steampowered.com/app/<id>/`.',\n        );\n    }\n    return s;\n}\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/steam/utils.js#L17-L53","documentation":"After the positivity check, requireBoundedInt enforces an upper bound: values greater than maxValue throw ArgumentError stating the limit. This keeps result-set sizes (and API load) bounded.","triggerScenarios":"Passing a limit larger than the command's maximum (e.g. --limit 100 when maxValue is 50).","commonSituations":"Users assuming 'no cap' and passing huge numbers; scripts copying limits from other CLIs with different bounds; confusion between page size and total results.","solutions":["Reduce the value to <= the stated maximum (see the error message for maxValue)","Omit the flag to use the default limit","Check the command's help text for the allowed range","Catch ArgumentError and clamp: n = Math.min(requested, maxValue)"],"exampleFix":"// before\n--limit 100\n// after\n--limit 50","handlingStrategy":"validation","validationCode":"const MAX = 50;\nconst n = Number(raw);\nif (Number.isInteger(n) && n > MAX) throw new Error(`limit must be <= ${MAX}`);","typeGuard":"function isWithinLimit(v, max) {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max;\n}","tryCatchPattern":"try {\n  await cmd({ limit: n });\n} catch (e) {\n  if (e instanceof ArgumentError && /must be <=/.test(e.message)) {\n    const max = Number(e.message.match(/<= (\\d+)/)?.[1] ?? 50);\n    return cmd({ limit: Math.min(n, max) }); // clamp and retry\n  } else throw e;\n}","preventionTips":["Clamp user-supplied limits to the documented max before calling","Show the allowed range in CLI help output","Avoid copying limits from other tools with different bounds","Test boundary values (max, max+1) in CI"],"tags":["validation","argument","steam","limits"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}