{"record":{"id":"57b6c5c9a5a4c501","repo":"thedotmack/claude-mem","slug":"cannot-bootstrap-server-api-key-claude-mem-server","errorCode":null,"errorMessage":"Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_URL is not set.","messagePattern":"Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_URL is not set\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/services/hooks/server-bootstrap.ts","lineNumber":225,"sourceCode":"    `SELECT id FROM projects WHERE team_id = $1 AND name = $2 LIMIT 1`,\n    [teamId, LOCAL_HOOK_PROJECT_NAME],\n  );\n  if (existing.rows[0]) {\n    return existing.rows[0].id;\n  }\n  const repo = new PostgresProjectsRepository(pool);\n  const project = await repo.create({\n    teamId,\n    name: LOCAL_HOOK_PROJECT_NAME,\n    metadata: { source: 'local-hook-bootstrap' },\n  });\n  return project.id;\n}\n\nfunction buildPoolFromEnv(): PostgresPool {\n  const config = parsePostgresConfig({ requireDatabaseUrl: true });\n  if (!config) {\n    throw new Error(\n      'Cannot bootstrap server API key: CLAUDE_MEM_SERVER_DATABASE_URL is not set.',\n    );\n  }\n  return createPostgresPool(config);\n}\n","sourceCodeStart":207,"sourceCodeEnd":231,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/hooks/server-bootstrap.ts#L207-L231","documentation":"Thrown by buildPoolFromEnv when bootstrap of the server API key requires a Postgres connection but the CLAUDE_MEM_SERVER_DATABASE_URL environment variable is not set. The library refuses to create a connection pool without a database URL because it has nowhere to store or look up the API key. This is a fail-fast configuration guard.","triggerScenarios":"Calling buildPoolFromEnv (directly or via the pool/bootstrap-server-key path) when the process environment has no CLAUDE_MEM_SERVER_DATABASE_URL, or when parsePostgresConfig with requireDatabaseUrl:true returns null because the variable is empty or whitespace.","commonSituations":"Running the server bootstrap in a fresh environment where .env was not loaded, deploying without the env var in the deployment manifest, or typo-ing the variable name (e.g. DATABASE_URL instead of CLAUDE_MEM_SERVER_DATABASE_URL).","solutions":["Set CLAUDE_MEM_SERVER_DATABASE_URL to a valid Postgres connection string in the environment before bootstrapping.","If using a .env file, confirm it is loaded by the process (dotenv/bun auto-load) and lives in the working directory.","Check deployment config (docker-compose, k8s secret, CI secrets) that the variable is injected under the exact name.","Verify the value is non-empty and parses as a postgres:// or postgresql:// URL."],"exampleFix":"// before\nbun run bootstrap\n// Error: Cannot bootstrap server API key...\n\n// after\nexport CLAUDE_MEM_SERVER_DATABASE_URL='postgres://user:pass@localhost:5432/claude_mem'\nbun run bootstrap","handlingStrategy":"validation","validationCode":"if (!process.env.CLAUDE_MEM_SERVER_DATABASE_URL?.trim()) {\n  throw new Error('CLAUDE_MEM_SERVER_DATABASE_URL must be set before bootstrapping the server API key');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a .env.example listing CLAUDE_MEM_SERVER_DATABASE_URL and copy it on setup.","Fail fast at process start with an env-var presence check.","Use exact env names in deployment manifests; avoid aliasing to DATABASE_URL."],"tags":["configuration","database","env-var","bootstrap"],"backgroundTag":"missing-env-var","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}