paperclipai/paperclip · error · Error
Failed to parse JSON at
Error message
Failed to parse JSON at ${filePath}: ${err instanceof Error ? err.message : String(err)} What it means
parseJson in the config store wraps JSON.parse of the config file and rethrows with the file path and parser message; the config file content is not valid JSON.
Solutions
- Fix the JSON syntax at ${filePath}.
- Restore the config from a backup or delete it so a fresh one is created.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at cli/src/config/store.ts:44 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@120ae5428f (2026-08-18).
Data as JSON: /api/errors/c5f2df070f6f6ee7.
Report an issue: GitHub.
Appendix: source
Thrown at cli/src/config/store.ts:44
const nextDir = path.resolve(currentDir, "..");
if (nextDir === currentDir) break;
currentDir = nextDir;
}
return null;
}
export function resolveConfigPath(overridePath?: string): string {
if (overridePath) return path.resolve(overridePath);
if (process.env.PAPERCLIP_CONFIG) return path.resolve(process.env.PAPERCLIP_CONFIG);
return findConfigFileFromAncestors(process.cwd()) ?? resolveDefaultConfigPath(resolvePaperclipInstanceId());
}
function parseJson(filePath: string): unknown {
try {
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
} catch (err) {
throw new Error(`Failed to parse JSON at ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
}
}
function migrateLegacyConfig(raw: unknown): unknown {
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
const config = { ...(raw as Record<string, unknown>) };
const databaseRaw = config.database;
if (typeof databaseRaw !== "object" || databaseRaw === null || Array.isArray(databaseRaw)) {
return config;
}
const database = { ...(databaseRaw as Record<string, unknown>) };
if (database.mode === "pglite") {
database.mode = "embedded-postgres";
if (typeof database.embeddedPostgresDataDir !== "string" && typeof database.pgliteDataDir === "string") {
database.embeddedPostgresDataDir = database.pgliteDataDir;
}View on GitHub (pinned to 120ae5428f)