apache/superset · error · ImportFailedError
Database doesn't exist and user doesn't have permission to c
Error message
Database doesn't exist and user doesn't have permission to create databases
What it means
ImportFailedError raised in superset/commands/database/importers/v1/utils.py (create_from_yaml / database config resolution) when the bundle's database UUID does not match any existing Database row and the current user lacks the 'can_write' permission on Database. Since the database must be created new but the user cannot create databases, the import aborts. Note can_write can be bypassed only when ignore_permissions is set (system/example imports), which normal REST imports do not set.
Source
Thrown at superset/commands/database/importers/v1/utils.py:55
logger = logging.getLogger(__name__)
def import_database( # noqa: C901
config: dict[str, Any],
overwrite: bool = False,
ignore_permissions: bool = False,
) -> Database:
can_write = ignore_permissions or security_manager.can_access(
"can_write",
"Database",
)
existing = db.session.query(Database).filter_by(uuid=config["uuid"]).first()
if existing:
if not overwrite or not can_write:
return existing
config["id"] = existing.id
elif not can_write:
raise ImportFailedError(
"Database doesn't exist and user doesn't have permission to create databases" # noqa: E501
)
# Check if this URI is allowed (skip for system imports like examples)
if app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] and not ignore_permissions:
try:
check_sqlalchemy_uri(make_url_safe(config["sqlalchemy_uri"]))
except SupersetSecurityException as exc:
raise ImportFailedError(exc.message) from exc
# https://github.com/apache/superset/pull/16756 renamed ``csv`` to ``file``.
# Handle both old and new field names, defaulting to True for examples database
if "allow_csv_upload" in config:
config["allow_file_upload"] = config.pop("allow_csv_upload")
elif "allow_file_upload" not in config:
# Default to True for backward compatibility
config["allow_file_upload"] = True
if "schemas_allowed_for_csv_upload" in config.get("extra", {}):
config["extra"]["schemas_allowed_for_file_upload"] = config["extra"].pop(View on GitHub (pinned to f4587218dd)
Solutions
- Have an Admin (or a role holding can_write on Database) perform the import.
- Or pre-create the database with the same UUID in the target environment (import just the database bundle first as Admin), so the user's import resolves an existing row and needs no create rights.
- Verify the user's effective permissions via their roles before handing them import workflows.
Example fix
# before: Gamma-like user imports bundle with unknown database uuid POST /api/v1/dashboard/import/ ... # -> ImportFailedError: Database doesn't exist and user doesn't have permission to create databases # after: admin pre-imports the database bundle once POST /api/v1/database/import/ (as Admin) # then the user's dashboard import resolves the existing database
Defensive patterns
Strategy: validation
Validate before calling
from superset import security_manager
def can_import_databases() -> bool:
return security_manager.can_access("can_write", "Database") Try / catch
from superset.commands.importers.exceptions import ImportFailedError
try:
dispatcher.run()
except ImportFailedError as ex:
if "doesn't have permission to create databases" in str(ex):
# escalate to an Admin or pre-create the database by UUID
... Prevention
- Route database-bearing imports through users holding can_write on Database.
- Pre-import the database bundle (as Admin) so later imports resolve an existing UUID and need no create rights.
- Check security_manager.can_access('can_write', 'Database') before offering the import button.
When it happens
Trigger: POST /api/v1/database/import/ by a user without can_write on Database, where the bundle contains a database UUID that does not exist in the target instance.
Common situations: Non-admin users importing dashboard bundles that embed a database not present in the target workspace; RBAC-hardened deployments where only Admins hold can_write on Database; importing into a fresh environment before the databases were set up.
Related errors
- A chart already exists and user doesn't have permissions to
- Chart doesn't exist and user doesn't have permission to crea
- Theme doesn't exist and user doesn't have permission to crea
- Cannot convert node type: ${node.type}
- User does not have permission to update the theme
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/7804181cbcba5422.
Report an issue: GitHub.