{"record":{"id":"f2c97686f91be6f3","repo":"paperclipai/paperclip","slug":"cannot-seed-worktree-database-because-source-local","errorCode":null,"errorMessage":"Cannot seed worktree database because source local_encrypted secrets key was not found at ${sourceKeyFilePath}.","messagePattern":"Cannot seed worktree database because source local_encrypted secrets key was not found at (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1090,"sourceCode":"      encoding: \"utf8\",\n      mode: 0o600,\n    });\n    try {\n      chmodSync(input.targetKeyFilePath, 0o600);\n    } catch {\n      // best effort\n    }\n    return;\n  }\n\n  const sourceKeyFileOverride =\n    nonEmpty(input.sourceEnvEntries.PAPERCLIP_SECRETS_MASTER_KEY_FILE) ??\n    (allowProcessEnvFallback ? nonEmpty(process.env.PAPERCLIP_SECRETS_MASTER_KEY_FILE) : null);\n  const sourceConfiguredKeyPath = sourceKeyFileOverride ?? input.sourceConfig.secrets.localEncrypted.keyFilePath;\n  const sourceKeyFilePath = resolveRuntimeLikePath(sourceConfiguredKeyPath, input.sourceConfigPath);\n\n  if (!existsSync(sourceKeyFilePath)) {\n    throw new Error(\n      `Cannot seed worktree database because source local_encrypted secrets key was not found at ${sourceKeyFilePath}.`,\n    );\n  }\n\n  copyFileSync(sourceKeyFilePath, input.targetKeyFilePath);\n  try {\n    chmodSync(input.targetKeyFilePath, 0o600);\n  } catch {\n    // best effort\n  }\n}\n\nexport async function ensureEmbeddedPostgres(\n  dataDir: string,\n  preferredPort: number,\n  options: { allowExisting?: boolean } = {},\n): Promise<EmbeddedPostgresHandle> {\n  const moduleName = \"embedded-postgres\";","sourceCodeStart":1072,"sourceCodeEnd":1108,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L1072-L1108","documentation":"Secrets-materialization guard during worktree seeding: the source instance uses local_encrypted secrets, and the master key file needed to decrypt/re-encrypt secrets for the new worktree does not exist at the resolved source path.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:1074 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the source local_encrypted secrets key file at the shown path before seeding the worktree database."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}