{"record":{"id":"f5c0bce7cc5343b8","repo":"Budibase/budibase","slug":"couchdb-password-not-set","errorCode":null,"errorMessage":"CouchDB password not set","messagePattern":"CouchDB password not set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/backend-core/src/db/couch/connections.ts","lineNumber":32,"sourceCode":"  // clean out any auth credentials\n  const urlInfo = getUrlInfo(connection)\n  let username\n  let password\n  if (urlInfo.auth?.username) {\n    // set from url\n    username = urlInfo.auth.username\n  } else if (credentials?.user) {\n    username = credentials?.user\n  } else {\n    throw new Error(\"CouchDB username not set\")\n  }\n  if (urlInfo.auth?.password) {\n    // set from url\n    password = urlInfo.auth.password\n  } else if (credentials?.password) {\n    password = credentials?.password\n  } else {\n    throw new Error(\"CouchDB password not set\")\n  }\n  const authCookie = Buffer.from(`${username}:${password}`).toString(\"base64\")\n  let sqlUrl = env.COUCH_DB_SQL_URL\n  if (!sqlUrl && urlInfo.url) {\n    const parsed = new URL(urlInfo.url)\n    parsed.port = env.COUCH_DB_SQS_PORT\n    sqlUrl = parsed.toString().replace(/\\/$/, \"\")\n  }\n  return {\n    url: urlInfo.url!,\n    // clean out any auth credentials\n    sqlUrl: getUrlInfo(sqlUrl).url,\n    auth: {\n      username: username,\n      password: password,\n    },\n    cookie: `Basic ${authCookie}`,\n  }","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/backend-core/src/db/couch/connections.ts#L14-L50","documentation":"parseCouchConnection resolves the CouchDB password from URL auth or credentials and throws when neither provides one. A username may exist, but the library will not connect without a password to build the basic-auth cookie.","triggerScenarios":"getCouchInfo() invoked when COUCH_DB_URL lacks a password in the auth segment and the credentials object/env has no password (COUCH_DB_PASSWORD unset or empty).","commonSituations":"Deployed with COUCH_DB_USER but forgotten COUCH_DB_PASSWORD; password containing special chars dropped by URL parsing; secrets manager returning undefined for the key; CouchDB started in admin-party mode with no password configured.","solutions":["Set the COUCH_DB_PASSWORD environment variable","Embed the password in the CouchDB URL (URL-encode special characters)","Pass an explicit { user, password } credentials object","Check secret injection (k8s secret / .env file) actually mounts the value"],"exampleFix":"// before\nconst password = config.dbPassword // undefined\n// after\nconst password = config.dbPassword ?? process.env.COUCH_DB_PASSWORD\nif (!password) throw new Error(\"Set COUCH_DB_PASSWORD\")","handlingStrategy":"validation","validationCode":"if (!process.env.COUCH_DB_PASSWORD && !/\\/[^/@]+:[^@]+@/.test(process.env.COUCH_DB_URL ?? \"\")) {\n  throw new Error(\"CouchDB password missing: set COUCH_DB_PASSWORD or embed in URL\")\n}","typeGuard":null,"tryCatchPattern":"try {\n  return getCouchInfo()\n} catch (e) {\n  if (e.message === \"CouchDB password not set\") {\n    console.error(\"Set COUCH_DB_PASSWORD or credentials before initializing db\")\n  }\n  throw e\n}","preventionTips":["Fail fast at boot when required CouchDB secrets are absent","URL-encode credentials embedded in COUCH_DB_URL","Verify secret manager keys mount under the exact env var names"],"tags":["couchdb","configuration","env","auth"],"backgroundTag":"missing-env-var","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}