{"record":{"id":"ed8b0405960a348a","repo":"jackwener/OpenCLI","slug":"flomo-memos-name-must-be-a-positive-integer","errorCode":null,"errorMessage":"flomo memos --${name} must be a positive integer","messagePattern":"flomo memos --(.+?) must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/flomo/memos.js","lineNumber":27,"sourceCode":"\nconst FLOMO_APP_DOMAIN = 'v.flomoapp.com';\nconst FLOMO_API_DOMAIN = 'flomoapp.com';\nconst MAX_LIMIT = 200;\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\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)) {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/flomo/memos.js#L9-L45","documentation":"This error is thrown by parsePositiveIntArg in clis/flomo/memos.js:27 when a numeric CLI option (e.g. --limit) passed to `flomo memos` is not a plain positive integer string. The library validates raw command-line input before using it as an API query parameter, and ArgumentError is raised so the user gets a clear message instead of a malformed request. The template interpolates the option name, so the actual message names the offending flag.","triggerScenarios":"Running `flomo memos --limit abc`, `--limit 10.5`, `--limit -3`, `--limit \" 12x \"`, `--limit \"\"` with surrounding invalid characters, or passing a value containing whitespace-plus-non-digits so the /^\\d+$/ test fails. Empty/undefined/null values are allowed and fall back, so only present-but-non-numeric values trigger this.","commonSituations":"Shell variables containing stray characters or units (e.g. LIMIT=20x), copy-pasting values with hidden characters or commas (1,000), passing floats or negative numbers assuming the CLI accepts them, or scripting with unquoted/interpolated values that end up empty-with-spaces or non-numeric.","solutions":["Pass a plain positive integer string, e.g. `flomo memos --limit 20`.","Check the variable you interpolate is numeric-only: `echo \"$LIMIT\"` and remove units, commas, or symbols.","Trim whitespace and validate with /^[0-9]+$/ in the calling script before invoking the CLI.","Omit the flag entirely to use the built-in fallback value."],"exampleFix":"// before\nflomo memos --limit \"1,000\"\n// after\nflomo memos --limit 1000","handlingStrategy":"validation","validationCode":"function isValidPositiveInt(v) { return v === undefined || v === null || v === '' || /^\\d+$/.test(String(v).trim()); }\nif (!isValidPositiveInt(process.env.LIMIT)) { throw new Error('limit must be a positive integer'); }","typeGuard":"function isPositiveIntString(v) { return typeof v === 'string' && /^\\d+$/.test(v.trim()); }","tryCatchPattern":"try {\n  await runMemos({ limit });\n} catch (err) {\n  if (err.name === 'ArgumentError' && err.message.includes('must be a positive integer')) {\n    console.error(`Invalid --limit value \"${limit}\"; using default.`);\n  } else { throw err; }\n}","preventionTips":["Quote and validate any shell variables before interpolating them into CLI flags.","Never include units, commas, or signs in numeric CLI arguments.","Validate with /^\\d+$/ in wrapper scripts before invoking the CLI.","Omit the flag rather than passing an empty/placeholder value."],"tags":["cli","argument-validation","input-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}