bito-code-review[bot] commented on PR #43687:
URL: https://github.com/apache/superset/pull/43687#issuecomment-5463633936
<!-- Bito Reply -->
The reviewer's assessment is correct. In Superset, API endpoints typically
use Marshmallow schemas (like `ChartPostSchema`) to validate incoming JSON
payloads before the command is instantiated. If the schema validation fails,
the request is rejected with a 400 Bad Request before the `CreateChartCommand`
is ever executed, making the 422 handling inside the command unreachable for
public API requests.
To resolve this, you should move the JSON validation logic into the
Marshmallow schema itself (e.g., using a `@validates` method or a custom field)
so that the validation error is raised during the schema-validation phase,
which is the appropriate place for handling malformed input.
**superset/commands/chart/create.py**
```
try:
params = json.loads(params_str)
except json.JSONDecodeError as ex:
raise ChartInvalidError(
exceptions=[ChartParamsInvalidJSONValidationError()]
) from ex
```
--
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]