{"record":{"id":"205e568e668be0f9","repo":"apache/superset","slug":"database-not-found-205e56","errorCode":null,"errorMessage":"Database not found.","messagePattern":"Database not found\\.","errorType":"exception","errorClass":"DatabaseNotFoundError","httpStatus":404,"severity":"error","filePath":"superset/commands/database/update.py","lineNumber":59,"sourceCode":"from superset.utils.decorators import on_error, transaction\n\nlogger = logging.getLogger(__name__)\n\n\nclass UpdateDatabaseCommand(BaseCommand):\n    _model: Database | None\n\n    def __init__(self, model_id: int, data: dict[str, Any]):\n        self._properties = data.copy()\n        self._model_id = model_id\n        self._model: Database | None = None\n\n    @transaction(on_error=partial(on_error, reraise=DatabaseUpdateFailedError))\n    def run(self) -> Model:\n        self._model = DatabaseDAO.find_by_id(self._model_id)\n\n        if not self._model:\n            raise DatabaseNotFoundError()\n\n        self.validate()\n\n        if \"masked_encrypted_extra\" in self._properties:\n            # unmask ``encrypted_extra``\n            self._properties[\"encrypted_extra\"] = (\n                self._model.db_engine_spec.unmask_encrypted_extra(\n                    self._model.encrypted_extra,\n                    self._properties.pop(\"masked_encrypted_extra\"),\n                )\n            )\n\n            # Depending on the changes to the OAuth2 configuration we may need to purge\n            # existing personal tokens.\n            self._handle_oauth2()\n\n        # Some DBs require running a query to get the default catalog.\n        # In these cases, if the current connection is broken then","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/database/update.py#L41-L77","documentation":"DatabaseNotFoundError raised in DatabaseUpdateCommand.run() when the model id to update no longer resolves. The whole update runs in a transaction whose error handler reraises wrapped failures as DatabaseUpdateFailedError, but a missing row aborts immediately with not-found.","triggerScenarios":"PUT /api/v1/database/<id> where the connection was deleted concurrently; optimistic UI editing on a stale id.","commonSituations":"Two admins editing/deleting the same connection; long-open edit dialogs; API retries after a deletion.","solutions":["Reload the connection list and re-apply the edit to the current id","Check for concurrent deletion before retrying","Use the UI's refreshed state rather than a stale dialog"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if not DatabaseDAO.find_by_id(db_id):\n    raise LookupError(f\"database {db_id} was deleted; reload and retry\")","typeGuard":null,"tryCatchPattern":"try:\n    DatabaseUpdateCommand(db_id, data).run()\nexcept DatabaseNotFoundError:\n    # reload connection, re-apply edit to current id\n    ...","preventionTips":["Shorten edit-dialog lifetime; coordinate concurrent admin edits","Recheck existence right before PUT"],"tags":["database","not-found","update","concurrency"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}