{"record":{"id":"cc61c2f293eb4d37","repo":"clockworklabs/SpacetimeDB","slug":"database-not-found","errorCode":null,"errorMessage":"Database not found: {}","messagePattern":"Database not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/standalone/src/lib.rs","lineNumber":499,"sourceCode":"    async fn replace_dns_records(\n        &self,\n        database_identity: &Identity,\n        owner_identity: &Identity,\n        domain_names: &[DomainName],\n    ) -> anyhow::Result<SetDomainsResult> {\n        Ok(self\n            .control_db\n            .spacetime_replace_domains(database_identity, owner_identity, domain_names)?)\n    }\n\n    async fn set_database_lock(\n        &self,\n        _caller_identity: &Identity,\n        database_identity: &Identity,\n        locked: bool,\n    ) -> anyhow::Result<()> {\n        let Some(_database) = self.control_db.get_database_by_identity(database_identity)? else {\n            anyhow::bail!(\"Database not found: {}\", database_identity.to_abbreviated_hex());\n        };\n        self.control_db.set_database_lock(database_identity, locked)?;\n        Ok(())\n    }\n}\n\nimpl spacetimedb_client_api::Authorization for StandaloneEnv {\n    async fn authorize_action(\n        &self,\n        subject: Identity,\n        database: Identity,\n        action: spacetimedb_client_api::Action,\n    ) -> Result<(), spacetimedb_client_api::Unauthorized> {\n        // Creating a database is always allowed.\n        if let spacetimedb_client_api::Action::CreateDatabase { .. } = action {\n            return Ok(());\n        }\n","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fb7282411b0b73cc68d51e161f180cd409abd851/crates/standalone/src/lib.rs#L481-L517","documentation":"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.","triggerScenarios":"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.","commonSituations":"Locking a database after its data directory was recreated; passing an identity copied from a different environment; automating locks against the wrong server URL.","solutions":["Confirm the database identity with spacetime list / spacetime describe and retry with the correct one.","Ensure the CLI/API targets the server instance where the database actually lives.","If the database was intentionally deleted, remove it from the automation that tries to lock it."],"exampleFix":"# before\nspacetime lock <wrong-identity> # -> Database not found: <abbrev>\n\n# after\nspacetime list\nspacetime lock <identity-from-list>","handlingStrategy":"validation","validationCode":"# before locking/unlocking, resolve the identity from the server itself:\nspacetime list\n# pass the identity shown there to the lock/unlock command","typeGuard":null,"tryCatchPattern":"match env.set_database_lock(&identity, locked).await {\n    Err(e) if e.to_string().contains(\"Database not found\") => {\n        // re-resolve identity via list/describe, then retry once\n    }\n    other => other,\n}","preventionTips":["Resolve database identities from the live server, never from stale notes.","Parameterize automation with database names and resolve identities at runtime.","Confirm the target server URL in admin scripts before identity-based calls."],"tags":["standalone","database-not-found","lock","administration"],"backgroundTag":"database-not-found","analyzedSha":"fb7282411b0b73cc68d51e161f180cd409abd851","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}