{"record":{"id":"e187096a96da9b4d","repo":"jackwener/OpenCLI","slug":"limit-must-be-an-integer-between-min-limit-an","errorCode":null,"errorMessage":"--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}","messagePattern":"--limit must be an integer between (.+?) and (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/barchart/greeks.js","lineNumber":36,"sourceCode":"\nfunction normalizeExpiration(value) {\n    const expiration = String(value ?? '').trim();\n    if (!expiration) return '';\n    if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(expiration)) {\n        throw new ArgumentError('--expiration must use YYYY-MM-DD format');\n    }\n    const parsed = new Date(`${expiration}T00:00:00Z`);\n    if (Number.isNaN(parsed.getTime()) || parsed.toISOString().slice(0, 10) !== expiration) {\n        throw new ArgumentError('--expiration must be a valid calendar date');\n    }\n    return expiration;\n}\n\nfunction parseLimit(value) {\n    if (value === undefined || value === null || value === '') return DEFAULT_LIMIT;\n    const limit = Number(value);\n    if (!Number.isInteger(limit) || limit < MIN_LIMIT || limit > MAX_LIMIT) {\n        throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}`);\n    }\n    return limit;\n}\n\nfunction unwrapBrowserResult(value) {\n    if (value && typeof value === 'object' && 'session' in value && 'data' in value) {\n        return value.data;\n    }\n    return value;\n}\n\ncli({\n    site: 'barchart',\n    name: 'greeks',\n    access: 'read',\n    description: 'Barchart options greeks overview (IV, delta, gamma, theta, vega)',\n    domain: 'www.barchart.com',\n    strategy: Strategy.COOKIE,","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/barchart/greeks.js#L18-L54","documentation":"parseLimit() applies defaults (10) for missing values but enforces that --limit is an integer within [MIN_LIMIT=1, MAX_LIMIT=100]. Any non-numeric, non-integer, out-of-range, or NaN value throws this ArgumentError with the interpolated message '--limit must be an integer between 1 and 100'.","triggerScenarios":"Passing --limit 0, --limit 101, --limit abc, --limit 2.5, or a blank-but-nonempty value like --limit \" \" that Number() coerces to NaN.","commonSituations":"Trying to fetch more than 100 rows and assuming a larger limit is allowed; passing a float from a computed script; shell variable interpolation producing empty/odd values; copy-paste typos like a trailing comma.","solutions":["Use an integer between 1 and 100, e.g. --limit 50.","Clamp the value in your script before calling: Math.min(100, Math.max(1, Math.round(n))).","If you need more than 100 rows, paginate by adjusting offsets/queries rather than raising --limit."],"exampleFix":"// before\n--limit 250\n// after\n--limit 100  // max allowed; paginate for more rows","handlingStrategy":"validation","validationCode":"const MIN_LIMIT = 1, MAX_LIMIT = 100;\nfunction clampLimit(v, fallback = 10) {\n  if (v === undefined || v === null || v === '') return fallback;\n  const n = Number(v);\n  if (!Number.isInteger(n) || n < MIN_LIMIT || n > MAX_LIMIT) {\n    throw new Error(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}`);\n  }\n  return n;\n}","typeGuard":"function isValidLimit(v) {\n  const n = Number(v);\n  return Number.isInteger(n) && n >= 1 && n <= 100;\n}","tryCatchPattern":"try {\n  await greeks({ symbol, limit });\n} catch (e) {\n  if (e.name === 'ArgumentError' && e.message.includes('--limit')) {\n    console.error('Use an integer 1-100 for --limit');\n    process.exitCode = 2;\n    return;\n  }\n  throw e;\n}","preventionTips":["Clamp computed limits with Math.min(100, Math.max(1, Math.round(n)))","Remember the hard max is 100; paginate for more rows","Coerce numeric CLI strings with Number() before passing"],"tags":["validation","argument-error","cli","range-check"],"backgroundTag":"argument-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}