bito-code-review[bot] commented on PR #42196:
URL: https://github.com/apache/superset/pull/42196#issuecomment-5024139774
<!-- Bito Reply -->
The flagged issue is correct. The current implementation of
`get_request_json_body()` returns the result of `request.get_json(cache=True)`
directly, which can be a non-dict value (e.g., `None`, `int`, `list`), causing
`get_form_data()` to crash when it attempts to access it as a mapping. To
resolve this, you should ensure the return value is always a dictionary by
checking the type of the result from `request.get_json()` and returning `{}` if
it is not a mapping.
**superset/views/utils.py**
```
def get_request_json_body() -> dict[Any, Any]:
if not request.is_json:
return {}
try:
data = request.get_json(cache=True)
return data if isinstance(data, dict) else {}
except BadRequest:
return {}
```
--
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]