{"record":{"id":"bbd9cfdba38b12e7","repo":"rohitg00/agentmemory","slug":"ignoring-max-files-raw-expected-a-positive-i-bbd9cf","errorCode":null,"errorMessage":"Ignoring --max-files=${raw}: expected a positive integer.","messagePattern":"Ignoring --max-files=(.+?): expected a positive integer\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli.ts","lineNumber":3683,"sourceCode":"    const a = tail[i]!;\n    if (a === \"--max-files\") {\n      const raw = tail[i + 1];\n      const parsed = raw !== undefined ? parseInt(raw, 10) : NaN;\n      if (Number.isInteger(parsed) && parsed > 0) {\n        maxFiles = parsed;\n      } else if (raw !== undefined) {\n        p.log.warn(`Ignoring --max-files ${raw}: expected a positive integer.`);\n      }\n      i++;\n      continue;\n    }\n    if (a.startsWith(\"--max-files=\")) {\n      const raw = a.slice(\"--max-files=\".length);\n      const parsed = parseInt(raw, 10);\n      if (Number.isInteger(parsed) && parsed > 0) {\n        maxFiles = parsed;\n      } else {\n        p.log.warn(`Ignoring --max-files=${raw}: expected a positive integer.`);\n      }\n      continue;\n    }\n    if (VALUE_FLAGS.has(a)) {\n      i++;\n      continue;\n    }\n    if (a.startsWith(\"-\")) continue;\n    positional.push(a);\n  }\n  const pathArg = positional[0];\n\n  const port = getRestPort();\n  const base = `http://localhost:${port}`;\n\n  let probeOk = false;\n  let probeDetail = \"\";\n  try {","sourceCodeStart":3665,"sourceCodeEnd":3701,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/cli.ts#L3665-L3701","documentation":"Same validation as the space-separated form, but for --max-files=<value>: the attached value is not a positive integer, so it is ignored and the default cap applies.","triggerScenarios":"`--max-files=` (empty), `--max-files=abc`, `--max-files=0`, `--max-files=-1`, or any non-integer attached value in the import-jsonl command.","commonSituations":"Copy-pasted values with units (1000k), empty assignment from scripted env substitution like --max-files=${MAX_FILES} where the var is unset.","solutions":["Provide a positive integer: --max-files=5000","In scripts, default the variable: MAX_FILES=\"${MAX_FILES:-5000}\"","Validate env-substituted values before passing them through"],"exampleFix":"// before\n$ agentmemory import-jsonl --max-files=${MAX_FILES}\nwarn: Ignoring --max-files=: expected a positive integer.\n// after\n$ MAX_FILES=\"${MAX_FILES:-5000}\"; agentmemory import-jsonl --max-files=$MAX_FILES","handlingStrategy":"validation","validationCode":"const raw = \"${MAX_FILES:-}\";\nif (!/^\\d+$/.test(raw) || parseInt(raw, 10) <= 0) throw new Error(\"--max-files= must be a positive integer\");","typeGuard":"function isPositiveInt(v: unknown): v is number { return Number.isInteger(v) && v > 0; }","tryCatchPattern":null,"preventionTips":["Default variables in scripts: MAX_FILES=\"${MAX_FILES:-5000}\"","Avoid unit suffixes (10k) — use plain integers","Echo the composed command in CI to catch empty substitutions"],"tags":["cli","argument-parsing","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}