{"record":{"id":"028424bf08bfe9bc","repo":"paperclipai/paperclip","slug":"lines-must-be-a-positive-integer","errorCode":null,"errorMessage":"--lines must be a positive integer.","messagePattern":"--lines must be a positive integer\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/service.ts","lineNumber":220,"sourceCode":"\n  common(service.command(\"restart\").description(\"Hot-restart the service while preserving active agent runs\"))\n    .option(\"--wait\", \"Wait for active runs to drain instead of adopting them\", false)\n    .option(\"--expected-version <version>\", \"Require the restarted server to report this version\")\n    .action(async (opts) => output(await restartManagedService({ instanceId: opts.instance, expectedVersion: opts.expectedVersion, waitForDrain: opts.wait }), opts.json));\n\n  common(service.command(\"status\").description(\"Show supervisor and health status\")).action(async (opts) => {\n    const manager = await resolveManager(opts); if (!manager) return;\n    const instanceId = resolvePaperclipInstanceId(opts.instance);\n    output({ ...await manager.status(), health: await probeHealth(instanceId) }, opts.json);\n  });\n\n  common(service.command(\"logs\").description(\"Show service logs\"))\n    .option(\"-f, --follow\", \"Follow new log output\", false)\n    .option(\"-n, --lines <count>\", \"Number of recent lines\", \"100\")\n    .action(async (opts) => {\n      const manager = await resolveManager(opts); if (!manager) return;\n      const lines = Number.parseInt(opts.lines, 10);\n      if (!Number.isInteger(lines) || lines < 1) throw new Error(\"--lines must be a positive integer.\");\n      await manager.logs(opts.follow, lines);\n    });\n}\n","sourceCodeStart":202,"sourceCodeEnd":224,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/service.ts#L202-L224","documentation":"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.","triggerScenarios":"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.","commonSituations":"Operators typing `--lines 0` meaning 'none', copy-pasting a count with units, or a wrapper passing an unset variable.","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."],"exampleFix":"# before\npaperclipai service logs -n 0\n# after\npaperclipai service logs -n 100","handlingStrategy":"validation","validationCode":"function parseLines(v: string): number {\n  const n = Number.parseInt(v, 10);\n  if (!Number.isInteger(n) || n < 1) throw new Error('--lines must be a positive integer.');\n  return n;\n}","typeGuard":"function isPositiveInt(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 1;\n}","tryCatchPattern":null,"preventionTips":["Use commander's built-in `parseInt` coercion for numeric options.","Default --lines to a sane positive value so omission never trips the guard."],"tags":["cli","validation","integer","service","logs"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}