diff --git a/superset/models/core.py b/superset/models/core.py index 7392e8796a571..b426849e709e5 100644 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -193,7 +193,12 @@ def json_data(self): @property def form_data(self): - form_data = json.loads(self.params) + form_data = {} + try: + form_data = json.loads(self.params) + except Exception as e: + logging.error("Malformed json in slice's params") + logging.exception(e) form_data.update({ 'slice_id': self.id, 'viz_type': self.viz_type, diff --git a/superset/views/core.py b/superset/views/core.py index 7d6db40abe85a..c38fe128e20b3 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -386,7 +386,11 @@ class SliceModelView(SupersetModelView, DeleteMixin): # noqa 'viz_type': _("Visualization Type"), } + def pre_add(self, obj): + utils.validate_json(obj.params) + def pre_update(self, obj): + utils.validate_json(obj.params) check_ownership(obj) def pre_delete(self, obj):