You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/12 20:44:55 UTC

[GitHub] [superset] codemaster08240328 commented on a diff in pull request #19672: fix: trap SQLAlchemy common exceptions & throw 422 error instead

codemaster08240328 commented on code in PR #19672:
URL: https://github.com/apache/superset/pull/19672#discussion_r848853572


##########
superset/views/base.py:
##########
@@ -231,6 +231,9 @@ def wraps(self: "BaseSupersetView", *args: Any, **kwargs: Any) -> FlaskResponse:
             return json_error_response(
                 utils.error_msg_from_exception(ex), status=cast(int, ex.code)
             )
+        except (exc.IntegrityError, exc.DatabaseError, exc.DataError) as ex:
+            logger.exception(ex)
+            return json_error_response(utils.error_msg_from_exception(ex), status=422)

Review Comment:
   Returning `422` status code for `DatabaseError` and `IntegrityError` is not good. Because these errors are not related to the entity which is sent from Client side. 
   
   `500` is more acceptable for these errors. 
   `422` is good for `DataError`
   
   Check here:
   https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
   https://docs.sqlalchemy.org/en/14/errors.html



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org