Budibase/budibase · error · Error

Unable to connect without URL or database

Error message

Unable to connect without URL or database

What it means

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.

Source

Thrown at packages/server/src/integrations/couchdb.ts:79

        id: {
          type: DatasourceFieldType.STRING,
          required: true,
        },
        rev: {
          type: DatasourceFieldType.STRING,
          required: true,
        },
      },
    },
  },
}

export class CouchDBIntegration implements IntegrationBase {
  private readonly client: Database

  constructor(config: CouchDBConfig) {
    if (!config.url || !config.database) {
      throw new Error("Unable to connect without URL or database")
    }
    this.client = dbCore.DatabaseWithConnection(config.database, config.url)
  }

  async testConnection() {
    const response: ConnectionInfo = {
      connected: false,
    }
    try {
      await this.client.allDocs({ limit: 1 })
      response.connected = true
    } catch (e: any) {
      response.error = e.message as string
    }
    return response
  }

  private parse(query: { json: string | object }) {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. 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
  2. Check the datasource record in the CouchDB/DB to confirm url and database are non-empty strings
  3. If using environment interpolation, verify the env vars referenced in the URL/database fields are actually set on the server
  4. Validate config before saving — reject submissions where url or database is blank

Example fix

// before
const config = { type: 'couchdb', database: '' } as CouchDBConfig
new CouchDBIntegration(config) // throws
// after
const config = { type: 'couchdb', url: 'http://localhost:5984', database: 'mydb' } as CouchDBConfig
new CouchDBIntegration(config)
Defensive patterns

Strategy: validation

Validate before calling

function validateCouchConfig(config) {
  const errors = []
  if (!config.url) errors.push('url is required')
  if (!config.database) errors.push('database is required')
  if (errors.length) throw new Error(`Invalid CouchDB config: ${errors.join(', ')}`)
}

Type guard

function isValidCouchConfig(config) {
  return typeof config?.url === 'string' && config.url.length > 0 &&
    typeof config?.database === 'string' && config.database.length > 0
}

Try / catch

try {
  const integration = new CouchDBIntegration(config)
} catch (err) {
  if (err.message.includes('Unable to connect without URL or database')) {
    // prompt user to complete datasource config
  } else throw err
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/1e6e8379e43c4384. Report an issue: GitHub.