paperclipai/paperclip · error · Error

Invalid integer value: ${value}

Error message

Invalid integer value: ${value}

What it means

parseOptionalInt (plugin.ts) parses a string option as base-10 integer and throws if the result is not finite or is negative. Used for plugin flags such as --duration-ms.

Source

Thrown at cli/src/commands/client/plugin.ts:950

            { json: ctx.json },
          );
        } catch (err) {
          handleCommandError(err);
        }
      }),
    { includeCompany: false },
  );
}

function parseJson(value: string): unknown {
  return JSON.parse(value) as unknown;
}

function parseOptionalInt(value: string | undefined): number | undefined {
  if (value === undefined) return undefined;
  const parsed = Number.parseInt(value, 10);
  if (!Number.isFinite(parsed) || parsed < 0) {
    throw new Error(`Invalid integer value: ${value}`);
  }
  return parsed;
}

async function streamPluginBridge(
  apiBase: string,
  apiKey: string | undefined,
  pluginId: string,
  channel: string,
  durationMs: number | undefined,
): Promise<void> {
  const controller = new AbortController();
  const timer = durationMs === undefined ? null : setTimeout(() => controller.abort(), durationMs);
  try {
    const response = await fetch(buildApiUrl(
      apiBase,
      `/api/plugins/${encodeURIComponent(pluginId)}/bridge/stream/${encodeURIComponent(channel)}`,
    ), {

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Pass a non-negative integer in milliseconds: `--duration-ms 5000`.
  2. Omit the flag to use the default (no timeout).
  3. Strip units/whitespace before passing.

Example fix

// before
paperclipai plugin stream plugin_x event --duration-ms -1
// after
paperclipai plugin stream plugin_x event --duration-ms 5000
Defensive patterns

Strategy: validation

Validate before calling

function parseOptionalInt(value?: string) {
  if (value === undefined) return undefined;
  const parsed = Number.parseInt(value, 10);
  if (!Number.isFinite(parsed) || parsed < 0) throw new Error(`Invalid integer value: ${value}`);
  return parsed;
}

Type guard

const isNonNegIntString = (v: string) => /^\d+$/.test(v.trim());

Prevention

When it happens

Trigger: Passing `--duration-ms abc`, `--duration-ms -1`, or a non-numeric/float value to a plugin command.

Common situations: Typo; passing seconds where ms is expected and including a sign; copy-pasted value with units like "500ms".

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/3289acac4e4a44ca. Report an issue: GitHub.