{"record":{"id":"1e6e8379e43c4384","repo":"Budibase/budibase","slug":"unable-to-connect-without-url-or-database","errorCode":null,"errorMessage":"Unable to connect without URL or database","messagePattern":"Unable to connect without URL or database","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/integrations/couchdb.ts","lineNumber":79,"sourceCode":"        id: {\n          type: DatasourceFieldType.STRING,\n          required: true,\n        },\n        rev: {\n          type: DatasourceFieldType.STRING,\n          required: true,\n        },\n      },\n    },\n  },\n}\n\nexport class CouchDBIntegration implements IntegrationBase {\n  private readonly client: Database\n\n  constructor(config: CouchDBConfig) {\n    if (!config.url || !config.database) {\n      throw new Error(\"Unable to connect without URL or database\")\n    }\n    this.client = dbCore.DatabaseWithConnection(config.database, config.url)\n  }\n\n  async testConnection() {\n    const response: ConnectionInfo = {\n      connected: false,\n    }\n    try {\n      await this.client.allDocs({ limit: 1 })\n      response.connected = true\n    } catch (e: any) {\n      response.error = e.message as string\n    }\n    return response\n  }\n\n  private parse(query: { json: string | object }) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/integrations/couchdb.ts#L61-L97","documentation":"The CouchDB integration constructs its client in the constructor and requires both a URL and a database name. Because connection happens at construction time, a config missing either field cannot proceed and the constructor throws immediately. Budibase validates the connection before any query or schema build can run.","triggerScenarios":"Saving or testing a CouchDB datasource whose `url` field is empty, or whose `database` field is empty, so CouchDBConfig has a falsy url/database when the integration is instantiated (constructor → DatabaseWithConnection never runs).","commonSituations":"Datasource form saved without filling the database field; environment interpolation produced an empty URL (unset env var); copy-pasting a config template with placeholder fields left blank; a fetch/partial-update endpoint sent a config with only some fields.","solutions":["Open the CouchDB datasource config in the Budibase builder and fill in both the URL (e.g. http://localhost:5984) and the database name, then re-test the connection","Check the datasource record in the CouchDB/DB to confirm url and database are non-empty strings","If using environment interpolation, verify the env vars referenced in the URL/database fields are actually set on the server","Validate config before saving — reject submissions where url or database is blank"],"exampleFix":"// before\nconst config = { type: 'couchdb', database: '' } as CouchDBConfig\nnew CouchDBIntegration(config) // throws\n// after\nconst config = { type: 'couchdb', url: 'http://localhost:5984', database: 'mydb' } as CouchDBConfig\nnew CouchDBIntegration(config)","handlingStrategy":"validation","validationCode":"function validateCouchConfig(config) {\n  const errors = []\n  if (!config.url) errors.push('url is required')\n  if (!config.database) errors.push('database is required')\n  if (errors.length) throw new Error(`Invalid CouchDB config: ${errors.join(', ')}`)\n}","typeGuard":"function isValidCouchConfig(config) {\n  return typeof config?.url === 'string' && config.url.length > 0 &&\n    typeof config?.database === 'string' && config.database.length > 0\n}","tryCatchPattern":"try {\n  const integration = new CouchDBIntegration(config)\n} catch (err) {\n  if (err.message.includes('Unable to connect without URL or database')) {\n    // prompt user to complete datasource config\n  } else throw err\n}","preventionTips":["Require url and database fields in the datasource form (client-side required validation)","Expand env-var interpolations and fail fast if they resolve to empty strings","Run testConnection right after saving config to catch incomplete setups"],"tags":["couchdb","connection","configuration"],"backgroundTag":"missing-required-config","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}