{"record":{"id":"978567fc0fc4dbaf","repo":"jackwener/OpenCLI","slug":"flomo-memos-name-must-be-between-1-and-max","errorCode":null,"errorMessage":"flomo memos --${name} must be between 1 and ${max}","messagePattern":"flomo memos --(.+?) must be between 1 and (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/flomo/memos.js","lineNumber":31,"sourceCode":"\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\nfunction parsePositiveIntArg(value, name, fallback, max) {\n  if (value === undefined || value === null || value === '') {\n    return fallback;\n  }\n  const text = String(value).trim();\n  if (!/^\\d+$/.test(text)) {\n    throw new ArgumentError(`flomo memos --${name} must be a positive integer`);\n  }\n  const parsed = Number(text);\n  if (!Number.isSafeInteger(parsed) || parsed < 1 || parsed > max) {\n    throw new ArgumentError(`flomo memos --${name} must be between 1 and ${max}`);\n  }\n  return parsed;\n}\n\nfunction parseSinceArg(value) {\n  if (value === undefined || value === null || value === '') {\n    return 0;\n  }\n  const text = String(value).trim();\n  if (!/^\\d+$/.test(text)) {\n    throw new ArgumentError('flomo memos --since must be a non-negative Unix timestamp in seconds');\n  }\n  const parsed = Number(text);\n  if (!Number.isSafeInteger(parsed)) {\n    throw new ArgumentError('flomo memos --since must be a safe integer Unix timestamp in seconds');\n  }\n  return parsed;\n}","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/flomo/memos.js#L13-L49","documentation":"Thrown by parsePositiveIntArg in clis/flomo/memos.js:31 when the value IS digits-only but falls outside the accepted range: it exceeds Number.MAX_SAFE_INTEGER, is less than 1, or is greater than the option's configured max. The message interpolates the option name and the max bound (e.g. \"must be between 1 and 100\"). It exists to prevent absurd or oversized pagination values from being sent to the flomo API.","triggerScenarios":"`flomo memos --limit 0`, `--limit 99999999999999999999999` (unsafe integer), or `--limit 500` when the flag's max is, say, 100. Any digits-only value failing Number.isSafeInteger(parsed) || parsed < 1 || parsed > max.","commonSituations":"Trying to fetch \"all\" memos with a huge limit, passing 0 assuming it means \"no limit\", or a config/env value tuned for a different tool's larger maximum.","solutions":["Read the error message for the exact max and pass a value within 1..max, e.g. `flomo memos --limit 100`.","To retrieve many memos, use the maximum allowed limit plus the --slug cursor for pagination instead of one huge limit.","If you used 0 expecting unlimited, use the fallback (omit the flag) or the max value.","Clamp in your wrapper script: `LIMIT=$(( LIMIT > 100 ? 100 : LIMIT ))` before calling the CLI."],"exampleFix":"// before\nflomo memos --limit 0\n// after\nflomo memos --limit 100  # or omit --limit for the default","handlingStrategy":"validation","validationCode":"const MAX = 100; // see error message for actual bound\nfunction inRange(v) { const n = Number(String(v).trim()); return Number.isSafeInteger(n) && n >= 1 && n <= MAX; }\nif (!inRange(limit)) limit = Math.min(Math.max(Number(limit) || 1, 1), MAX);","typeGuard":"function isInRange(v, max) { const n = Number(v); return Number.isSafeInteger(n) && n >= 1 && n <= max; }","tryCatchPattern":"try {\n  await runMemos({ limit });\n} catch (err) {\n  if (err.name === 'ArgumentError' && err.message.includes('must be between 1 and')) {\n    const max = Number(err.message.match(/between 1 and (\\d+)/)?.[1]);\n    limit = Math.min(limit, max || 100);\n  } else { throw err; }\n}","preventionTips":["Never use 0 to mean \"unlimited\"; omit the flag for defaults.","Paginate with the cursor (--slug) instead of inflating --limit.","Clamp values to the documented max in wrapper scripts.","Beware numbers larger than 2^53-1; they lose precision in JS."],"tags":["cli","argument-validation","range-check"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}