{"record":{"id":"a20a866c1be6b8d6","repo":"paperclipai/paperclip","slug":"path-must-be-a-positive-finite-number","errorCode":null,"errorMessage":"${path} must be a positive finite number","messagePattern":"(.+?) must be a positive finite number","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/cli/eval-session-contract.ts","lineNumber":129,"sourceCode":"  }\n  return Number(value);\n}\n\nexport function expectedEvalSessionDriver(\n  provider: EvalSessionProvider,\n): EvalSessionDriver {\n  return provider === \"opencode\"\n    ? \"opencode_server\"\n    : provider === \"claude_managed\"\n      ? \"claude_managed_agents_api\"\n      : provider === \"aws_agentcore\"\n        ? \"aws_agentcore_harness_api\"\n    : provider === \"acpx\" ? \"acpx_runtime\" : \"codex_app_server\";\n}\n\nfunction positiveNumber(value: unknown, path: string): number {\n  if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) {\n    throw new Error(`${path} must be a positive finite number`);\n  }\n  return value;\n}\n\nfunction parseManagedProfile(value: unknown): EvalSessionManagedProfile {\n  const profile = object(value, \"request.managedProfile\");\n  if (profile.betaVersion !== \"managed-agents-2026-04-01\") {\n    throw new Error(\"request.managedProfile.betaVersion is not qualified\");\n  }\n  const agentVersion = text(\n    profile.agentVersion,\n    \"request.managedProfile.agentVersion\",\n  );\n  if (\n    !/^[1-9][0-9]*$/.test(agentVersion) ||\n    BigInt(agentVersion) > 2_147_483_647n\n  ) {\n    throw new Error(","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/src/cli/eval-session-contract.ts#L111-L147","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send a finite number > 0 for the path named in the error","Coerce numeric strings with Number() and check Number.isFinite before sending","Fix the upstream computation that produced NaN/Infinity","If 0 is legitimate for this field, the contract must be updated — otherwise clamp/omit the field"],"exampleFix":"// before\nconst profile = { agentVersion: '42', maxCostNanodollars: '1000' };\n// after\nconst profile = { agentVersion: '42', maxCostNanodollars: 1000 };","handlingStrategy":"validation","validationCode":"function isPositiveFiniteNumber(v) {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0;\n}\nif (!isPositiveFiniteNumber(profile.maxCost)) throw new Error('maxCost must be a positive finite number');","typeGuard":"function isPositiveFinite(v) {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0;\n}","tryCatchPattern":"try {\n  const request = parseEvalSessionRequest(raw);\n} catch (err) {\n  if (err.message.includes('must be a positive finite number')) {\n    throw new RequestValidationError('Profile numeric field must be a finite number > 0', { cause: err });\n  }\n  throw err;\n}","preventionTips":["Coerce numeric strings from JSON config to real numbers before sending","Check computations that feed these fields for NaN/Infinity propagation","Decide explicitly whether 0 is valid; if so change the contract, otherwise clamp upstream","Round/validate floats (e.g. costs) at the producer"],"tags":["validation","contract","numbers"],"backgroundTag":"schema-validation-failed","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}