paperclipai/paperclip · error · Error

request.managedProfile.agentVersion must be a canonical posi

Error message

request.managedProfile.agentVersion must be a canonical positive int32 string

What it means

Within parseManagedProfile, agentVersion must be a string of only digits 1-9 followed by digits (no leading zeros, no sign), whose numeric value fits in a signed int32 (<= 2147483647, checked via BigInt). Anything else — '0', '007', 'abc', '1.5', a number type, or an oversized value — throws this error.

Source

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

    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(
      "request.managedProfile.agentVersion must be a canonical positive int32 string",
    );
  }
  return {
    profileId: text(profile.profileId, "request.managedProfile.profileId"),
    anthropicAgentId: text(
      profile.anthropicAgentId,
      "request.managedProfile.anthropicAgentId",
    ),
    agentVersion,
    environmentId: text(
      profile.environmentId,
      "request.managedProfile.environmentId",
    ),
    betaVersion: "managed-agents-2026-04-01",
    maxSessionListCostUsd: positiveNumber(
      profile.maxSessionListCostUsd,
      "request.managedProfile.maxSessionListCostUsd",

View on GitHub (pinned to 01ad858492)

Solutions

  1. Send agentVersion as a canonical decimal string: /^[1-9][0-9]*$/ and <= 2147483647
  2. Convert numeric values with String(n) before submitting, after verifying they are positive int32
  3. Normalize inputs by stripping non-digit prefixes ('v42' → '42') and rejecting leading zeros
  4. If the real id exceeds int32, escalate — the managed-agents contract only supports int32 versions

Example fix

// before
{ agentVersion: 42 }
// after
{ agentVersion: '42' }
Defensive patterns

Strategy: validation

Validate before calling

function isCanonicalInt32String(v) {
  return typeof v === 'string' && /^[1-9][0-9]*$/.test(v) && BigInt(v) <= 2147483647n;
}
if (!isCanonicalInt32String(req.managedProfile?.agentVersion)) {
  throw new Error('agentVersion must be a canonical positive int32 string');
}

Type guard

const isAgentVersion = (v) => typeof v === 'string' && /^[1-9][0-9]*$/.test(v) && BigInt(v) <= 2_147_483_647n;

Try / catch

try {
  const request = parseEvalSessionRequest(raw);
} catch (err) {
  if (err.message.includes('canonical positive int32')) {
    throw new RequestValidationError('agentVersion must be a digit string like "42" — no leading zeros, no floats, max 2147483647', { cause: err });
  }
  throw err;
}

Prevention

When it happens

Trigger: request.managedProfile.agentVersion is '0', has leading zeros, is negative, is a float string, is not a string at all (e.g. the number 42), or exceeds 2147483647.

Common situations: A caller sends agentVersion as a JSON number instead of a string; a version like 'v42' or '42.0' is passed through unnormalized; an upstream 64-bit id was assigned where only int32 is supported; a placeholder '0' was never replaced.

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/5063643340a4f53a. Report an issue: GitHub.