rusackas commented on code in PR #40536:
URL: https://github.com/apache/superset/pull/40536#discussion_r3328052382
##########
superset/commands/chart/create.py:
##########
@@ -43,6 +44,11 @@ class CreateChartCommand(CreateMixin, BaseCommand):
def __init__(self, data: dict[str, Any]):
self._properties = data.copy()
+ if params_str := self._properties.get("params"):
+ params = json.loads(params_str)
+ if isinstance(params, dict) and "viz_type" in params:
+ self._properties["viz_type"] = params["viz_type"]
Review Comment:
Good catch — fixed in bae380f. Switched from direct assignment to
`setdefault()` so the top-level `viz_type` wins when both it and a `viz_type`
inside `params` are supplied.
##########
superset/commands/chart/create.py:
##########
@@ -43,6 +44,11 @@ class CreateChartCommand(CreateMixin, BaseCommand):
def __init__(self, data: dict[str, Any]):
self._properties = data.copy()
+ if params_str := self._properties.get("params"):
+ params = json.loads(params_str)
Review Comment:
The marshmallow schema for chart creation (`superset/charts/schemas.py`)
already applies `validate=utils.validate_json` to the `params` field before the
request reaches `CreateChartCommand.__init__`, so `json.loads` here cannot
raise `JSONDecodeError` in normal operation. Adding a catch would be dead code
— declining this one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]