clockworklabs/SpacetimeDB · error

Database not found: {}

Error message

Database not found: {}

What it means

set_database_lock on the standalone environment first resolves the database by identity from the control database. If the lookup returns None the operation bails with the abbreviated identity, refusing to lock/unlock an unknown database.

Source

Thrown at crates/standalone/src/lib.rs:499

    async fn replace_dns_records(
        &self,
        database_identity: &Identity,
        owner_identity: &Identity,
        domain_names: &[DomainName],
    ) -> anyhow::Result<SetDomainsResult> {
        Ok(self
            .control_db
            .spacetime_replace_domains(database_identity, owner_identity, domain_names)?)
    }

    async fn set_database_lock(
        &self,
        _caller_identity: &Identity,
        database_identity: &Identity,
        locked: bool,
    ) -> anyhow::Result<()> {
        let Some(_database) = self.control_db.get_database_by_identity(database_identity)? else {
            anyhow::bail!("Database not found: {}", database_identity.to_abbreviated_hex());
        };
        self.control_db.set_database_lock(database_identity, locked)?;
        Ok(())
    }
}

impl spacetimedb_client_api::Authorization for StandaloneEnv {
    async fn authorize_action(
        &self,
        subject: Identity,
        database: Identity,
        action: spacetimedb_client_api::Action,
    ) -> Result<(), spacetimedb_client_api::Unauthorized> {
        // Creating a database is always allowed.
        if let spacetimedb_client_api::Action::CreateDatabase { .. } = action {
            return Ok(());
        }

View on GitHub (pinned to fb7282411b)

Solutions

  1. Confirm the database identity with spacetime list / spacetime describe and retry with the correct one.
  2. Ensure the CLI/API targets the server instance where the database actually lives.
  3. If the database was intentionally deleted, remove it from the automation that tries to lock it.

Example fix

# before
spacetime lock <wrong-identity> # -> Database not found: <abbrev>

# after
spacetime list
spacetime lock <identity-from-list>
Defensive patterns

Strategy: validation

Validate before calling

# before locking/unlocking, resolve the identity from the server itself:
spacetime list
# pass the identity shown there to the lock/unlock command

Try / catch

match env.set_database_lock(&identity, locked).await {
    Err(e) if e.to_string().contains("Database not found") => {
        // re-resolve identity via list/describe, then retry once
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling the lock/unlock API (e.g. spacetime lock / unlock or the HTTP control endpoint) with a database identity that is not registered in this standalone instance.

Common situations: Locking a database after its data directory was recreated; passing an identity copied from a different environment; automating locks against the wrong server URL.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@fb7282411b (2026-08-20). Data as JSON: /api/errors/cc61c2f293eb4d37. Report an issue: GitHub.