{"record":{"id":"c6066dd8ef968353","repo":"paperclipai/paperclip","slug":"path-must-be-a-positive-safe-integer","errorCode":null,"errorMessage":"${path} must be a positive safe integer","messagePattern":"(.+?) must be a positive safe integer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/cli/eval-session-contract.ts","lineNumber":110,"sourceCode":"}\n\nfunction object(value: unknown, path: string): Record<string, unknown> {\n  if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n    throw new Error(`${path} must be an object`);\n  }\n  return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, path: string): string {\n  if (typeof value !== \"string\" || value.trim().length === 0) {\n    throw new Error(`${path} must be a non-empty string`);\n  }\n  return value;\n}\n\nfunction positiveInteger(value: unknown, path: string): number {\n  if (!Number.isSafeInteger(value) || Number(value) <= 0) {\n    throw new Error(`${path} must be a positive safe integer`);\n  }\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) {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/src/cli/eval-session-contract.ts#L92-L128","documentation":"The positiveInteger() helper validates that a value is a safe integer greater than zero, using Number.isSafeInteger plus a >0 check, and throws '<path> must be a positive safe integer' otherwise. Applied to numeric fields parsed by parseAgentCoreProfile and parseEvalSessionRequest.","triggerScenarios":"A numeric field validated with positiveInteger() is 0, negative, a float, NaN, a numeric string, or an integer beyond Number.MAX_SAFE_INTEGER (e.g. large int64 values sent as JSON numbers).","commonSituations":"Limits/counts default to 0 when unset; a caller sends a string like \"5\" from JSON config; an upstream 64-bit id exceeds the safe-integer range and should be transported as a string instead.","solutions":["Send the value as an actual JS number that is an integer >= 1","If the value is a string, convert with Number() and validate before passing","For very large identifiers, keep them as strings in the contract instead of numbers","Fix default initialization so unset counters do not fall back to 0"],"exampleFix":"// before\nconst req = { schema: SCHEMA, provider: 'codex', timeoutSeconds: '30' };\n// after\nconst req = { schema: SCHEMA, provider: 'codex', timeoutSeconds: 30 };","handlingStrategy":"validation","validationCode":"function isPositiveSafeInt(v) {\n  return Number.isSafeInteger(v) && v > 0;\n}\nif (!isPositiveSafeInt(payload.count)) throw new Error('count must be a positive safe integer');","typeGuard":"function isPositiveSafeInteger(v) {\n  return typeof v === 'number' && Number.isSafeInteger(v) && v > 0;\n}","tryCatchPattern":"try {\n  const request = parseEvalSessionRequest(raw);\n} catch (err) {\n  if (err.message.includes('must be a positive safe integer')) {\n    throw new RequestValidationError('Numeric field out of range or wrong type — send an integer >= 1 as a number', { cause: err });\n  }\n  throw err;\n}","preventionTips":["Never default numeric counters to 0 when the contract requires >= 1","Transport large int64 ids as strings, not JSON numbers","Coerce config strings with Number() and validate before submission","Add type checks at the producer so stringly-typed numbers never reach the contract"],"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"}