paperclipai/paperclip · error
--lines must be a positive integer.
Error message
--lines must be a positive integer.
What it means
Thrown by the `service logs` action when `--lines` (`-n`) cannot be parsed as a positive integer. It mirrors the CLI's positive-int validation: Number.parseInt must succeed and the result must be >= 1.
Source
Thrown at cli/src/commands/service.ts:220
common(service.command("restart").description("Hot-restart the service while preserving active agent runs"))
.option("--wait", "Wait for active runs to drain instead of adopting them", false)
.option("--expected-version <version>", "Require the restarted server to report this version")
.action(async (opts) => output(await restartManagedService({ instanceId: opts.instance, expectedVersion: opts.expectedVersion, waitForDrain: opts.wait }), opts.json));
common(service.command("status").description("Show supervisor and health status")).action(async (opts) => {
const manager = await resolveManager(opts); if (!manager) return;
const instanceId = resolvePaperclipInstanceId(opts.instance);
output({ ...await manager.status(), health: await probeHealth(instanceId) }, opts.json);
});
common(service.command("logs").description("Show service logs"))
.option("-f, --follow", "Follow new log output", false)
.option("-n, --lines <count>", "Number of recent lines", "100")
.action(async (opts) => {
const manager = await resolveManager(opts); if (!manager) return;
const lines = Number.parseInt(opts.lines, 10);
if (!Number.isInteger(lines) || lines < 1) throw new Error("--lines must be a positive integer.");
await manager.logs(opts.follow, lines);
});
}
View on GitHub (pinned to 67001ec6eb)
Solutions
- Pass a positive integer: `paperclipai service logs -n 200`.
- If you want few lines, use `1` as the minimum; `0` is not supported.
- Ensure shell variables feeding `-n` are set and numeric.
Example fix
# before paperclipai service logs -n 0 # after paperclipai service logs -n 100
Defensive patterns
Strategy: validation
Validate before calling
function parseLines(v: string): number {
const n = Number.parseInt(v, 10);
if (!Number.isInteger(n) || n < 1) throw new Error('--lines must be a positive integer.');
return n;
} Type guard
function isPositiveInt(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v >= 1;
} Prevention
- Use commander's built-in `parseInt` coercion for numeric options.
- Default --lines to a sane positive value so omission never trips the guard.
When it happens
Trigger: Running `paperclipai service logs -n <count>` with a value like `0`, `-5`, `3.5`, `abc`, or empty. The producer is `Number.parseInt(opts.lines, 10)` followed by `!Number.isInteger(lines) || lines < 1` at service.ts:220.
Common situations: Operators typing `--lines 0` meaning 'none', copy-pasting a count with units, or a wrapper passing an unset variable.
Related errors
- Invalid ${label}: ${value}
- --payload must be a JSON object
- ${name} must be a JSON object
- Invalid ${name} JSON: ${err instanceof Error ? err.message :
- --file is required
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/028424bf08bfe9bc.
Report an issue: GitHub.