paperclipai/paperclip · error · Error

${path} must be a positive finite number

Error message

${path} must be a positive finite number

What it means

The positiveNumber() helper validates that a value is a finite number greater than zero (rejecting NaN and Infinity) and throws '<path> must be a positive finite number' otherwise. Used by parseManagedProfile and parseAgentCoreProfile for numeric cost/limit fields.

Source

Thrown at packages/paperclip-runner/src/cli/eval-session-contract.ts:129

  }
  return Number(value);
}

export function expectedEvalSessionDriver(
  provider: EvalSessionProvider,
): EvalSessionDriver {
  return provider === "opencode"
    ? "opencode_server"
    : provider === "claude_managed"
      ? "claude_managed_agents_api"
      : provider === "aws_agentcore"
        ? "aws_agentcore_harness_api"
    : provider === "acpx" ? "acpx_runtime" : "codex_app_server";
}

function positiveNumber(value: unknown, path: string): number {
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
    throw new Error(`${path} must be a positive finite number`);
  }
  return value;
}

function parseManagedProfile(value: unknown): EvalSessionManagedProfile {
  const profile = object(value, "request.managedProfile");
  if (profile.betaVersion !== "managed-agents-2026-04-01") {
    throw new Error("request.managedProfile.betaVersion is not qualified");
  }
  const agentVersion = text(
    profile.agentVersion,
    "request.managedProfile.agentVersion",
  );
  if (
    !/^[1-9][0-9]*$/.test(agentVersion) ||
    BigInt(agentVersion) > 2_147_483_647n
  ) {
    throw new Error(

View on GitHub (pinned to 01ad858492)

Solutions

  1. Send a finite number > 0 for the path named in the error
  2. Coerce numeric strings with Number() and check Number.isFinite before sending
  3. Fix the upstream computation that produced NaN/Infinity
  4. If 0 is legitimate for this field, the contract must be updated — otherwise clamp/omit the field

Example fix

// before
const profile = { agentVersion: '42', maxCostNanodollars: '1000' };
// after
const profile = { agentVersion: '42', maxCostNanodollars: 1000 };
Defensive patterns

Strategy: validation

Validate before calling

function isPositiveFiniteNumber(v) {
  return typeof v === 'number' && Number.isFinite(v) && v > 0;
}
if (!isPositiveFiniteNumber(profile.maxCost)) throw new Error('maxCost must be a positive finite number');

Type guard

function isPositiveFinite(v) {
  return typeof v === 'number' && Number.isFinite(v) && v > 0;
}

Try / catch

try {
  const request = parseEvalSessionRequest(raw);
} catch (err) {
  if (err.message.includes('must be a positive finite number')) {
    throw new RequestValidationError('Profile numeric field must be a finite number > 0', { cause: err });
  }
  throw err;
}

Prevention

When it happens

Trigger: A numeric field validated with positiveNumber() is <= 0, NaN, Infinity, -Infinity, or a non-number type (string/boolean/null) in a managed or agentCore profile.

Common situations: A metrics/limits field serialized as a string from JSON; a division or computation produced NaN/Infinity before submission; a cost of 0 was sent for a field requiring strictly positive values.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-02). Data as JSON: /api/errors/a20a866c1be6b8d6. Report an issue: GitHub.