{"record":{"id":"d857345f9228636f","repo":"paperclipai/paperclip","slug":"source-instance-uses-postgres-mode-but-has-no-conn","errorCode":null,"errorMessage":"Source instance uses postgres mode but has no connection string in config or adjacent .env.","messagePattern":"Source instance uses postgres mode but has no connection string in config or adjacent \\.env\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":1027,"sourceCode":"    throw new Error(extractExecSyncErrorMessage(error) ?? String(error));\n  }\n\n  installDependenciesBestEffort(targetPath);\n\n  return {\n    rootPath: targetPath,\n    configPath: path.resolve(targetPath, \".paperclip\", \"config.json\"),\n    label: branchName,\n    branchName,\n    created: true,\n  };\n}\n\nfunction resolveSourceConnectionString(config: PaperclipConfig, envEntries: Record<string, string>, portOverride?: number): string {\n  if (config.database.mode === \"postgres\") {\n    const connectionString = nonEmpty(envEntries.DATABASE_URL) ?? nonEmpty(config.database.connectionString);\n    if (!connectionString) {\n      throw new Error(\n        \"Source instance uses postgres mode but has no connection string in config or adjacent .env.\",\n      );\n    }\n    return connectionString;\n  }\n\n  const port = portOverride ?? config.database.embeddedPostgresPort;\n  return `postgres://paperclip:paperclip@127.0.0.1:${port}/paperclip`;\n}\n\nexport function copySeededSecretsKey(input: {\n  sourceConfigPath: string;\n  sourceConfig: PaperclipConfig;\n  sourceEnvEntries: Record<string, string>;\n  targetKeyFilePath: string;\n}): void {\n  if (input.sourceConfig.secrets.provider !== \"local_encrypted\") {\n    return;","sourceCodeStart":1009,"sourceCodeEnd":1045,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L1009-L1045","documentation":"Thrown by resolveSourceConnectionString when the source config has database.mode === 'postgres' but neither the adjacent .env's DATABASE_URL nor config.database.connectionString yields a connection string. The reseed needs a live postgres URL to dump/copy from the source.","triggerScenarios":"Source instance configured for external postgres but DATABASE_URL was never set; .env missing or not loaded; connectionString field omitted from config.json; secrets stripped from config for security.","commonSituations":"Source .env not copied during clone; DATABASE_URL set only in the running process env, not in the file; config generated by a template that omits connectionString; switching a source instance to postgres mode without populating the URL.","solutions":["Set DATABASE_URL in the source instance's adjacent .env (or connectionString in config.json) to the postgres connection string.","Confirm the .env file is readable by the CLI user and not gitignored away.","If the source uses embedded-postgres mode instead, change config.database.mode to 'embedded-postgres' so the default localhost URL applies.","Verify readPaperclipEnvEntries is loading the correct .env next to the source config."],"exampleFix":"# before: source .env has no DATABASE_URL\n# after\nDATABASE_URL=postgres://user:pass@host:5432/paperclip","handlingStrategy":"validation","validationCode":"function hasSourceConnectionString(config: PaperclipConfig, env: Record<string, string>): boolean {\n  return config.database.mode !== 'postgres' || Boolean(nonEmpty(env.DATABASE_URL) ?? nonEmpty(config.database.connectionString));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set DATABASE_URL in the source instance .env when using postgres mode.","Validate source config before invoking reseed.","Keep connectionString and DATABASE_URL in sync."],"tags":["database","postgres","config","env","reseed"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}