apache/superset · error · DatabaseRequiredFieldValidationError
Field is required
Error message
Field is required
What it means
DatabaseRequiredFieldValidationError raised with 'Field is required' semantics when the sqlalchemy_uri property is missing from the create payload. Two guards exist: validate() appends DatabaseRequiredFieldValidationError('sqlalchemy_uri') when self._properties.get('sqlalchemy_uri') is falsy, and run() re-checks 'sqlalchemy_uri' not in self._properties before making the URL. The message text 'Field is required' is the base ValidationError default for a missing field.
Source
Thrown at superset/commands/database/create.py:62
from superset.exceptions import OAuth2RedirectError, SupersetErrorsException
from superset.extensions import event_logger
from superset.models.core import Database
from superset.utils.decorators import on_error, transaction
logger = logging.getLogger(__name__)
stats_logger = app.config["STATS_LOGGER"]
class CreateDatabaseCommand(BaseCommand):
def __init__(self, data: dict[str, Any]):
self._properties = data.copy()
@transaction(on_error=partial(on_error, reraise=DatabaseCreateFailedError))
def run(self) -> Model:
self.validate()
if "sqlalchemy_uri" not in self._properties:
raise DatabaseRequiredFieldValidationError("sqlalchemy_uri")
url = make_url_safe(self._properties["sqlalchemy_uri"])
engine = url.get_backend_name()
try:
# Test connection before starting create transaction
TestConnectionDatabaseCommand(self._properties).run()
except OAuth2RedirectError:
# If we can't connect to the database due to an OAuth2 error we can still
# save the database. Later, the user can sync permissions when setting up
# data access rules.
return self._create_database()
except (
SupersetErrorsException,
SSHTunnelingNotEnabledError,
SSHTunnelDatabasePortError,
SSHTunnelHostKeyVerificationError,
) as ex:View on GitHub (pinned to f4587218dd)
Solutions
- Include a well-formed sqlalchemy_uri, e.g. 'postgresql://user:pass@host:5432/db'.
- Check for key-name typos and casing — the REST field is exactly sqlalchemy_uri.
- If building the payload programmatically, assert the key exists before POSTing.
Example fix
# before
POST /api/v1/database/
{"database_name": "mydb"} # missing URI
# after
{"database_name": "mydb", "sqlalchemy_uri": "postgresql://user:pass@host:5432/db"} Defensive patterns
Strategy: validation
Validate before calling
def valid_create_payload(data: dict) -> bool:
return bool(data.get("database_name")) and bool(data.get("sqlalchemy_uri")) Type guard
def is_create_database_payload(data: dict) -> bool:
return (
isinstance(data, dict)
and isinstance(data.get("database_name"), str)
and isinstance(data.get("sqlalchemy_uri"), str)
and "://" in data["sqlalchemy_uri"]
) Prevention
- Assert both database_name and sqlalchemy_uri are non-empty strings before POSTing.
- Use the exact field names of the REST schema (sqlalchemy_uri, not uri/sqlalchemyUri).
- Validate the payload against the database POST schema marshmallow exposes.
When it happens
Trigger: POST /api/v1/database/ with a JSON body lacking sqlalchemy_uri (or with it null / empty string — run() then also fails make_url_safe or the key check).
Common situations: Client sends only database_name; a form or Terraform/Ansible module drops the field; typo like 'sqlalchemyUri' or 'uri' instead of sqlalchemy_uri; JSON body malformed so fields land nowhere.
Related errors
- Annotation layer parameters are invalid.
- Dashboard parameters are invalid.
- Connection failed, please check your connection settings
- Database could not be created.
- Database not found.
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/b11cc388df749315.
Report an issue: GitHub.