{"record":{"id":"51965efe8abdb769","repo":"paperclipai/paperclip","slug":"invalid-config-at-configpath-expected-a-json-o","errorCode":null,"errorMessage":"Invalid config at ${configPath}: expected a JSON object","messagePattern":"Invalid config at (.+?): expected a JSON object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/db/src/runtime-config.ts","lineNumber":156,"sourceCode":"  const rounded = Math.trunc(value);\n  return rounded > 0 ? rounded : null;\n}\n\nfunction readConfig(configPath: string): PartialConfig | null {\n  if (!existsSync(configPath)) return null;\n\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(readFileSync(configPath, \"utf8\"));\n  } catch (err) {\n    throw new Error(\n      `Failed to parse config at ${configPath}: ${err instanceof Error ? err.message : String(err)}`,\n    );\n  }\n\n  const migrated = migrateLegacyConfig(parsed);\n  if (migrated === null || typeof migrated !== \"object\" || Array.isArray(migrated)) {\n    throw new Error(`Invalid config at ${configPath}: expected a JSON object`);\n  }\n\n  const database =\n    typeof migrated.database === \"object\" &&\n    migrated.database !== null &&\n    !Array.isArray(migrated.database)\n      ? migrated.database\n      : undefined;\n\n  return {\n    database: database\n      ? {\n          mode: database.mode === \"postgres\" ? \"postgres\" : \"embedded-postgres\",\n          connectionString:\n            typeof database.connectionString === \"string\" ? database.connectionString : undefined,\n          embeddedPostgresDataDir:\n            typeof database.embeddedPostgresDataDir === \"string\"\n              ? database.embeddedPostgresDataDir","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/db/src/runtime-config.ts#L138-L174","documentation":"Error \"Invalid config at ${configPath}: expected a JSON object\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/db/src/runtime-config.ts:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the config file contains a top-level JSON object `{...}`, not an array or scalar."],"exampleFix":null,"handlingStrategy":null,"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-14T05:17:10.506Z"}