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
- Ensure the value passed to parseEvalSessionRequest is a decoded JSON object (not a JSON string — call JSON.parse first if needed)
- Check the path in the error message to find which field is not an object and fix the producer to send an object there
- Remove null/array values at that path before validation
- 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
- Always JSON.parse string payloads before calling parseEvalSessionRequest
- Never send null or arrays where an object is required
- Keep request construction in one typed factory so shapes cannot drift
- Log the failing path from the error message to pinpoint the malformed field
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
- ${path} must be a non-empty string
- ${path} must be a positive safe integer
- ${path} must be a positive finite number
- request.managedProfile.betaVersion is not qualified
- request.managedProfile.agentVersion must be a canonical posi
AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-02).
Data as JSON: /api/errors/246100a23df93644.
Report an issue: GitHub.