Budibase/budibase · error

DB does not exist

Error message

DB does not exist

What it means

DatabaseImpl.checkAndCreateDb checks whether the underlying CouchDB database exists. When instance creation is disabled via skip_setup and the DB is absent, it throws instead of silently creating it. This prevents code from operating on databases that were never provisioned.

Source

Thrown at packages/backend-core/src/db/couch/DatabaseImpl.ts:160

    } catch {
      return false
    }
  }

  private nano() {
    return this.instanceNano || DatabaseImpl.nano
  }

  private getDb() {
    return this.nano().db.use(this.name)
  }

  private async checkAndCreateDb() {
    let shouldCreate = !this.pouchOpts?.skip_setup
    // check exists in a lightweight fashion
    let exists = await this.exists()
    if (!shouldCreate && !exists) {
      throw new Error("DB does not exist")
    }
    if (!exists) {
      try {
        await this.nano().db.create(this.name)
      } catch (err: any) {
        // Handling race conditions
        if (err.statusCode !== 412) {
          throw new CouchDBError(err.message, err)
        }
      }
    }
    return this.getDb()
  }

  // this function fetches the DB and handles if DB creation is needed
  private async performCallWithDBCreation<T>(
    call: DBCallback<T>
  ): Promise<any> {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Ensure the DB is created through the normal provisioning path (create the app/workspace) before accessing it
  2. If creation is intended, drop skip_setup so checkAndCreateDb creates the DB
  3. Verify CouchDB connection settings/replicas — the DB may exist on another node/instance
  4. Check for typos in the DB name and that the right tenant/environment is targeted

Example fix

// before
const db = new DatabaseImpl(name, { skip_setup: true })
// after
const db = new DatabaseImpl(name) // allow auto-create
await db.exists() ? null : await db.checkAndCreateDb()
Defensive patterns

Strategy: fallback

Validate before calling

const db = getDB(name, { skip_setup: true })
if (!(await db.exists())) {
  // provision or fail fast before real work
}

Try / catch

try {
  await db.put(doc)
} catch (err) {
  if (err.message === "DB does not exist") {
    // create the DB via provisioning path, then retry
  } else throw err
}

Prevention

When it happens

Trigger: Constructing/opening a Database with pouchOpts.skip_setup=true (the default for workspace DBs) while the named DB does not exist in CouchDB; e.g. opening an app DB that was deleted or never created.

Common situations: Pointing at a fresh CouchDB instance without running provisioning/migrations, typos in DB names, apps deleted while background jobs still reference them, restore/backup gaps.

Related errors


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