feat: generic marshmallow error component (#25303)

This commit is contained in:
Beto Dealmeida
2023-10-03 11:35:28 -07:00
committed by GitHub
parent dbe0838f8f
commit 3e63c82ecc
13 changed files with 376 additions and 35 deletions

View File

@@ -332,7 +332,6 @@ class DatasetRestApi(BaseSupersetModelRestApi):
@expose("/<pk>", methods=("PUT",))
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",

View File

@@ -24,6 +24,7 @@ from marshmallow.validate import Length
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
from superset.datasets.models import Dataset
from superset.exceptions import SupersetMarshmallowValidationError
get_delete_ids_schema = {"type": "array", "items": {"type": "integer"}}
get_export_ids_schema = {"type": "array", "items": {"type": "integer"}}
@@ -125,6 +126,17 @@ class DatasetPutSchema(Schema):
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
def handle_error(
self,
error: ValidationError,
data: dict[str, Any],
**kwargs: Any,
) -> None:
"""
Return SIP-40 error.
"""
raise SupersetMarshmallowValidationError(error, data)
class DatasetDuplicateSchema(Schema):
base_model_id = fields.Integer(required=True)