{"record":{"id":"c935d2bfa6a96e3d","repo":"jackwener/OpenCLI","slug":"upwork-label-must-be-max","errorCode":null,"errorMessage":"upwork ${label} must be <= ${max}","messagePattern":"upwork (.+?) must be <= (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/upwork/utils.js","lineNumber":68,"sourceCode":"export function requireQuery(value, label = 'query') {\n    const q = String(value ?? '').trim();\n    if (!q) throw new ArgumentError(`upwork ${label} cannot be empty`);\n    return q;\n}\n\nexport function requirePositiveInt(value, defaultValue, label) {\n    const raw = value ?? defaultValue;\n    const n = coerceInt(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`upwork ${label} must be a positive integer`);\n    }\n    return n;\n}\n\nexport function requireBoundedInt(value, defaultValue, min, max, label) {\n    const n = requirePositiveInt(value, defaultValue, label);\n    if (n < min) throw new ArgumentError(`upwork ${label} must be >= ${min}`);\n    if (n > max) throw new ArgumentError(`upwork ${label} must be <= ${max}`);\n    return n;\n}\n\n/**\n * Upwork job ids are the ciphertext form starting with `~01` or `~02`\n * (the encoded uid surfaced everywhere in URLs and search results).\n * Accepts a bare ciphertext or a full `/jobs/~02…` URL.\n */\nexport function requireCiphertext(value) {\n    let id = String(value ?? '').trim();\n    if (!id) throw new ArgumentError('upwork job id is required');\n    const urlMatch = id.match(/~0[12]\\d+/);\n    if (urlMatch) id = urlMatch[0];\n    if (!CIPHERTEXT_PATTERN.test(id)) {\n        throw new ArgumentError(`upwork job id \"${value}\" is not a valid ciphertext (expected ~01… or ~02… followed by digits)`);\n    }\n    return id;\n}","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/upwork/utils.js#L50-L86","documentation":"The upper-bound branch of requireBoundedInt: throws ArgumentError when the integer option exceeds the allowed maximum. Prevents absurdly large limits/pages from being sent to Upwork or blowing up row mapping.","triggerScenarios":"Passing an option like `limit` with a value greater than `max` (e.g. --limit 1000 when max is 100); a script or alias supplying an unbounded count value.","commonSituations":"Automations that request 'all results' by setting a huge limit; users assuming limits are unlimited; defaults migrated from another adapter with looser caps.","solutions":["Lower the option value to at most the maximum shown in the message","Use pagination (page option) instead of a giant limit to fetch more results","Omit the option to use the built-in default"],"exampleFix":"// before\n$ opencli upwork search \"vue\" --limit 500\n// error: upwork limit must be <= 100\n// after\n$ opencli upwork search \"vue\" --limit 100\n// then paginate: --page 2","handlingStrategy":"validation","validationCode":"const n = Number(limit);\nif (!Number.isInteger(n) || n > max) throw new RangeError(`limit must be <= ${max}`);","typeGuard":"function isBoundedInt(v, min, max) {\n  return Number.isInteger(v) && v >= min && v <= max;\n}","tryCatchPattern":"try {\n  return await cmd({ limit });\n} catch (e) {\n  if (e instanceof ArgumentError && /must be <=/.test(e.message)) {\n    return cmd({ limit: MAX_LIMIT });\n  }\n  throw e;\n}","preventionTips":["Paginate with --page instead of raising limit","Cap automation inputs at the documented max","Never pass 'all results' style sentinel values as limits"],"tags":["validation","cli","argument-error","upwork"],"backgroundTag":"option-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}