{"record":{"id":"692dee93a317340f","repo":"apache/superset","slug":"database-not-found-692dee","errorCode":null,"errorMessage":"Database not found.","messagePattern":"Database not found\\.","errorType":"exception","errorClass":"DatabaseNotFoundError","httpStatus":404,"severity":"error","filePath":"superset/commands/database/uploaders/base.py","lineNumber":283,"sourceCode":"    def _resolve_default_schema(database: Database) -> Optional[str]:\n        \"\"\"Resolve the database's default schema so uploaded datasets carry an\n        explicit schema instead of NULL, which would otherwise duplicate an\n        existing dataset over the same table (see #36305).\"\"\"\n        try:\n            return database.get_default_schema(database.get_default_catalog())\n        except Exception:  # pylint: disable=broad-except\n            # Resolution opens an inspector connection; a failure here must\n            # degrade to the no-schema behavior rather than fail the upload.\n            logger.warning(\n                \"Unable to resolve default schema for upload; proceeding without one\",\n                exc_info=True,\n            )\n            return None\n\n    def validate(self) -> None:\n        self._model = DatabaseDAO.find_by_id(self._model_id)\n        if not self._model:\n            raise DatabaseNotFoundError()\n        engine_resolved = False\n        if not self._schema:\n            self._schema = self._resolve_default_schema(self._model)\n            engine_resolved = self._schema is not None\n        if not schema_allows_file_upload(\n            self._model, self._schema, engine_resolved=engine_resolved\n        ):\n            raise DatabaseSchemaUploadNotAllowed()\n        if not self._model.db_engine_spec.supports_file_upload:\n            raise DatabaseUploadNotSupported()\n\n        self.validate_file_size(self._file)\n","sourceCodeStart":265,"sourceCodeEnd":296,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/database/uploaders/base.py#L265-L296","documentation":"DatabaseNotFoundError raised in UploadCommand.validate() when DatabaseDAO.find_by_id(self._model_id) returns None. The upload pipeline (CSV/Excel to database) first asserts the target connection exists.","triggerScenarios":"POST upload to /api/v1/database/<id>/upload with a nonexistent connection id; connection deleted while the upload dialog was open.","commonSituations":"Stale frontend state; scripted uploads with hardcoded ids; connection removed between dialog load and submit.","solutions":["Reload the connection list and select a valid database","Verify with GET /api/v1/database/<id> before uploading","Restore the deleted connection if the upload must target it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if not DatabaseDAO.find_by_id(db_id):\n    raise LookupError(f\"database {db_id} does not exist\")\nUploadCommand(db_id, ...).run()","typeGuard":null,"tryCatchPattern":"try:\n    UploadCommand(...).run()\nexcept DatabaseNotFoundError:\n    # refresh connection list, retry with valid id\n    ...","preventionTips":["Re-validate connection ids at submit time in upload UIs","Script uploads should fail fast on unknown ids"],"tags":["database","upload","not-found"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}