{"record":{"id":"c5f2df070f6f6ee7","repo":"paperclipai/paperclip","slug":"failed-to-parse-json-at-filepath-err-instanc-c5f2df","errorCode":null,"errorMessage":"Failed to parse JSON at ${filePath}: ${err instanceof Error ? err.message : String(err)}","messagePattern":"Failed to parse JSON at (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/config/store.ts","lineNumber":44,"sourceCode":"    const nextDir = path.resolve(currentDir, \"..\");\n    if (nextDir === currentDir) break;\n    currentDir = nextDir;\n  }\n\n  return null;\n}\n\nexport function resolveConfigPath(overridePath?: string): string {\n  if (overridePath) return path.resolve(overridePath);\n  if (process.env.PAPERCLIP_CONFIG) return path.resolve(process.env.PAPERCLIP_CONFIG);\n  return findConfigFileFromAncestors(process.cwd()) ?? resolveDefaultConfigPath(resolvePaperclipInstanceId());\n}\n\nfunction parseJson(filePath: string): unknown {\n  try {\n    return JSON.parse(fs.readFileSync(filePath, \"utf-8\"));\n  } catch (err) {\n    throw new Error(`Failed to parse JSON at ${filePath}: ${err instanceof Error ? err.message : String(err)}`);\n  }\n}\n\nfunction migrateLegacyConfig(raw: unknown): unknown {\n  if (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return raw;\n  const config = { ...(raw as Record<string, unknown>) };\n  const databaseRaw = config.database;\n  if (typeof databaseRaw !== \"object\" || databaseRaw === null || Array.isArray(databaseRaw)) {\n    return config;\n  }\n\n  const database = { ...(databaseRaw as Record<string, unknown>) };\n  if (database.mode === \"pglite\") {\n    database.mode = \"embedded-postgres\";\n\n    if (typeof database.embeddedPostgresDataDir !== \"string\" && typeof database.pgliteDataDir === \"string\") {\n      database.embeddedPostgresDataDir = database.pgliteDataDir;\n    }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/config/store.ts#L26-L62","documentation":"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.","triggerScenarios":"Thrown at cli/src/config/store.ts:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the JSON syntax at ${filePath}.","Restore the config from a backup or delete it so a fresh one is created."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}