rohitg00/agentmemory · warning

Ignoring --max-files=${raw}: expected a positive integer.

Error message

Ignoring --max-files=${raw}: expected a positive integer.

What it means

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.

Source

Thrown at src/cli.ts:3683

    const a = tail[i]!;
    if (a === "--max-files") {
      const raw = tail[i + 1];
      const parsed = raw !== undefined ? parseInt(raw, 10) : NaN;
      if (Number.isInteger(parsed) && parsed > 0) {
        maxFiles = parsed;
      } else if (raw !== undefined) {
        p.log.warn(`Ignoring --max-files ${raw}: expected a positive integer.`);
      }
      i++;
      continue;
    }
    if (a.startsWith("--max-files=")) {
      const raw = a.slice("--max-files=".length);
      const parsed = parseInt(raw, 10);
      if (Number.isInteger(parsed) && parsed > 0) {
        maxFiles = parsed;
      } else {
        p.log.warn(`Ignoring --max-files=${raw}: expected a positive integer.`);
      }
      continue;
    }
    if (VALUE_FLAGS.has(a)) {
      i++;
      continue;
    }
    if (a.startsWith("-")) continue;
    positional.push(a);
  }
  const pathArg = positional[0];

  const port = getRestPort();
  const base = `http://localhost:${port}`;

  let probeOk = false;
  let probeDetail = "";
  try {

View on GitHub (pinned to e04ba88819)

Solutions

  1. Provide a positive integer: --max-files=5000
  2. In scripts, default the variable: MAX_FILES="${MAX_FILES:-5000}"
  3. Validate env-substituted values before passing them through

Example fix

// before
$ agentmemory import-jsonl --max-files=${MAX_FILES}
warn: Ignoring --max-files=: expected a positive integer.
// after
$ MAX_FILES="${MAX_FILES:-5000}"; agentmemory import-jsonl --max-files=$MAX_FILES
Defensive patterns

Strategy: validation

Validate before calling

const raw = "${MAX_FILES:-}";
if (!/^\d+$/.test(raw) || parseInt(raw, 10) <= 0) throw new Error("--max-files= must be a positive integer");

Type guard

function isPositiveInt(v: unknown): v is number { return Number.isInteger(v) && v > 0; }

Prevention

When it happens

Trigger: `--max-files=` (empty), `--max-files=abc`, `--max-files=0`, `--max-files=-1`, or any non-integer attached value in the import-jsonl command.

Common situations: Copy-pasted values with units (1000k), empty assignment from scripted env substitution like --max-files=${MAX_FILES} where the var is unset.

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


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/bbd9cfdba38b12e7. Report an issue: GitHub.