paperclipai/paperclip · error · Error
Invalid JSON: ${error instanceof Error ? error.message : Str
Error message
Invalid JSON: ${error instanceof Error ? error.message : String(error)} What it means
Error "Invalid JSON: ${error instanceof Error ? error.message : String(error)}" thrown in paperclipai/paperclip.
Source
Thrown at cli/src/commands/pipelines.ts:696
return Object.keys(edits).length ? edits : undefined;
}
async function readJsonFromOptions(json?: string, file?: string): Promise<unknown | undefined> {
if (json && file) throw new Error("Pass either inline JSON or a JSON file, not both.");
if (json) return parseJson(json);
if (file) return readJsonFile(file);
return undefined;
}
async function readJsonFile(file: string): Promise<unknown> {
return parseJson(await readFile(file, "utf8"));
}
function parseJson(value: string): unknown {
try {
return JSON.parse(value) as unknown;
} catch (error) {
throw new Error(`Invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
}
}
function asObject(value: unknown): JsonObject {
if (!value || typeof value !== "object" || Array.isArray(value)) {
throw new Error("Expected a JSON object.");
}
return value as JsonObject;
}
function asOptionalObject(value: unknown): JsonObject | undefined {
return value && typeof value === "object" && !Array.isArray(value) ? value as JsonObject : undefined;
}
function parsePositiveInt(value: string, label: string): number {
const parsed = Number(value);
if (!Number.isInteger(parsed) || parsed <= 0) throw new Error(`Invalid ${label}: ${value}`);
return parsed;View on GitHub (pinned to 67001ec6eb)
When it happens
Trigger: Thrown at cli/src/commands/pipelines.ts:696 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/3762566da585227d.
Report an issue: GitHub.