{"record":{"id":"84b158847b599cfe","repo":"jackwener/OpenCLI","slug":"limit-must-be-between-min-limit-and-max-lim-84b158","errorCode":null,"errorMessage":"--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed}","messagePattern":"--limit must be between (.+?) and (.+?), got (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/trip/utils.js","lineNumber":58,"sourceCode":"    if (month < 1 || month > 12 || day < 1 || day > 31) {\n        throw new ArgumentError(`--${name} has invalid month/day: ${value}`);\n    }\n    // Cross-check via UTC date math so 2026-02-30 doesn't pass.\n    const parsed = new Date(Date.UTC(year, month - 1, day));\n    if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) {\n        throw new ArgumentError(`--${name} is not a real calendar date: ${value}`);\n    }\n    return value;\n}\n\nexport function parseListLimit(raw, fallback = 20) {\n    if (raw === undefined || raw === null || raw === '') return fallback;\n    const parsed = Number(raw);\n    if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) {\n        throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${JSON.stringify(raw)}`);\n    }\n    if (parsed < MIN_LIMIT || parsed > MAX_LIMIT) {\n        throw new ArgumentError(`--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed}`);\n    }\n    return parsed;\n}\n\nexport function buildFlightSearchUrl(fromCode, toCode, date) {\n    const params = new URLSearchParams({\n        dcity: fromCode.toLowerCase(),\n        acity: toCode.toLowerCase(),\n        ddate: date,\n        triptype: 'ow',\n        class: 'y',\n        quantity: '1',\n        locale: 'en_US',\n        curr: 'USD',\n    });\n    return `https://www.trip.com/flights/showfarefirst?${params.toString()}`;\n}\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/utils.js#L40-L76","documentation":"parseListLimit throws this when the value is an integer but falls outside the configured MIN_LIMIT/MAX_LIMIT bounds. It's a range check after the integer check, so the value parses fine but is simply too small or too large for list queries.","triggerScenarios":"Calling limit with --limit 0, --limit -5, or an extremely large value such as --limit 100000 that exceeds MAX_LIMIT (the bounds come from the MIN_LIMIT/MAX_LIMIT constants).","commonSituations":"Passing 0 or a negative to mean 'unlimited'; assuming pagination size limits of other tools apply here; config files with page-size values from a different service.","solutions":["Set --limit within the documented bounds shown in the error message","If you want everything, use the maximum allowed value for --limit instead of 0 or a huge number","Paginate with repeated calls if you need more results than MAX_LIMIT","Check the CLI help or source constants for the exact MIN/MAX values"],"exampleFix":"// before\nclis-trip hotels --city-id 338 --checkin 2026-10-01 --checkout 2026-10-05 --limit 0\n// after\nclis-trip hotels --city-id 338 --checkin 2026-10-01 --checkout 2026-10-05 --limit 20","handlingStrategy":"validation","validationCode":"const n = Number(limit);\nif (limit !== undefined && Number.isInteger(n) && (n < MIN || n > MAX)) {\n  throw new Error(`--limit must be between ${MIN} and ${MAX}, got ${n}`);\n}","typeGuard":"function isLimitInRange(v, min, max) {\n  const n = Number(v);\n  return Number.isInteger(n) && n >= min && n <= max;\n}","tryCatchPattern":"try {\n  runTripCli(['hotels', '--limit', limit]);\n} catch (err) {\n  if (err instanceof ArgumentError && /--limit must be between/.test(err.message)) {\n    console.error(`--limit out of range: ${err.message}. Clamp or paginate instead.`);\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Clamp limit values to the documented MIN/MAX before invoking","Never use 0 or negatives to mean 'unlimited' — use the max value","Paginate with repeated calls if results exceed MAX_LIMIT","Keep page-size configs per-service, not shared globally"],"tags":["cli","argument-validation","range"],"backgroundTag":"argument-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}