paperclipai/paperclip · error · Error

${path} must be an object

Error message

${path} must be an object

What it means

The object() helper in eval-session-contract.ts is the fail-closed validator for the eval-session executable boundary. It requires a decoded JSON value at a given path to be a plain object — not a string, number, boolean, null, or array. If it is not, it throws '<path> must be an object' with the exact request path in the message.

Source

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

  session: CreateCapabilityLiveSessionInput;
  nativeResume?: { operationId: string };
  /** Current live sessions always use Codex collaboration instructions. */
  includeCollaborationModeInstructions?: true;
}

export interface EvalSessionUsage extends EstimatedModelCost {
  agentTurns: number;
  providerRequests: number;
  inputTokens: number;
  outputTokens: number;
  cachedInputTokens: number;
  reasoningTokens: number;
  providerReportedCostNanodollars: number;
}

function object(value: unknown, path: string): Record<string, unknown> {
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
    throw new Error(`${path} must be an object`);
  }
  return value as Record<string, unknown>;
}

function text(value: unknown, path: string): string {
  if (typeof value !== "string" || value.trim().length === 0) {
    throw new Error(`${path} must be a non-empty string`);
  }
  return value;
}

function positiveInteger(value: unknown, path: string): number {
  if (!Number.isSafeInteger(value) || Number(value) <= 0) {
    throw new Error(`${path} must be a positive safe integer`);
  }
  return Number(value);
}

View on GitHub (pinned to 01ad858492)

Solutions

  1. Ensure the value passed to parseEvalSessionRequest is a decoded JSON object (not a JSON string — call JSON.parse first if needed)
  2. Check the path in the error message to find which field is not an object and fix the producer to send an object there
  3. Remove null/array values at that path before validation
  4. Align the caller's request payload with the current eval-session request schema

Example fix

// before
parseEvalSessionRequest(JSON.stringify(req));
// after
parseEvalSessionRequest(typeof req === 'string' ? JSON.parse(req) : req);
Defensive patterns

Strategy: type-guard

Validate before calling

function isPlainObject(v) {
  return typeof v === 'object' && v !== null && !Array.isArray(v);
}
if (!isPlainObject(rawRequest)) throw new Error('request payload must be a decoded JSON object');

Type guard

const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
function asRecord(v) { return isRecord(v) ? v : null; }

Try / catch

try {
  const request = parseEvalSessionRequest(raw);
} catch (err) {
  if (err.message.endsWith('must be an object')) {
    console.error('Malformed eval-session request at', err.message.split(' ')[0]);
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing a value that is not a plain object at any path validated with object(), e.g. request itself, request.managedProfile, request.agentCoreProfile, or a nested field, when it is null, an array, or a primitive.

Common situations: The eval-session request was serialized as a JSON array or string; a caller posted null; double-parsing turned the object into a string; a schema change made a nested profile field optional so it arrives undefined/null.

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/246100a23df93644. Report an issue: GitHub.