jackwener/OpenCLI · error · ArgumentError
flomo memos --${name} must be between 1 and ${max}
Error message
flomo memos --${name} must be between 1 and ${max} What it means
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.
Source
Thrown at clis/flomo/memos.js:31
function unwrapBrowserResult(value) {
if (value && typeof value === 'object' && 'session' in value && 'data' in value) {
return value.data;
}
return value;
}
function parsePositiveIntArg(value, name, fallback, max) {
if (value === undefined || value === null || value === '') {
return fallback;
}
const text = String(value).trim();
if (!/^\d+$/.test(text)) {
throw new ArgumentError(`flomo memos --${name} must be a positive integer`);
}
const parsed = Number(text);
if (!Number.isSafeInteger(parsed) || parsed < 1 || parsed > max) {
throw new ArgumentError(`flomo memos --${name} must be between 1 and ${max}`);
}
return parsed;
}
function parseSinceArg(value) {
if (value === undefined || value === null || value === '') {
return 0;
}
const text = String(value).trim();
if (!/^\d+$/.test(text)) {
throw new ArgumentError('flomo memos --since must be a non-negative Unix timestamp in seconds');
}
const parsed = Number(text);
if (!Number.isSafeInteger(parsed)) {
throw new ArgumentError('flomo memos --since must be a safe integer Unix timestamp in seconds');
}
return parsed;
}View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before flomo memos --limit 0 // after flomo memos --limit 100 # or omit --limit for the default
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 100; // see error message for actual bound
function inRange(v) { const n = Number(String(v).trim()); return Number.isSafeInteger(n) && n >= 1 && n <= MAX; }
if (!inRange(limit)) limit = Math.min(Math.max(Number(limit) || 1, 1), MAX); Type guard
function isInRange(v, max) { const n = Number(v); return Number.isSafeInteger(n) && n >= 1 && n <= max; } Try / catch
try {
await runMemos({ limit });
} catch (err) {
if (err.name === 'ArgumentError' && err.message.includes('must be between 1 and')) {
const max = Number(err.message.match(/between 1 and (\d+)/)?.[1]);
limit = Math.min(limit, max || 100);
} else { throw err; }
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- ${label} must be between ${min} and ${max}, got ${parsed}
- ${label} must be <= ${max}
- --${name} must be between ${min} and ${max}, got ${parsed}
- limit must be an integer between 1 and ${max}
- --limit must be an integer between 1 and 500
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/978567fc0fc4dbaf.
Report an issue: GitHub.