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 2020/09/21 14:45:34 UTC

[GitHub] [incubator-superset] zhaoyongjie opened a new pull request #10977: Minor refactor, remove unreachable codes

zhaoyongjie opened a new pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977


   ### SUMMARY
   remove unreachable codes, all the request exception catch by marshmallow.
   ```
           response = self.response_400(
               message=f"Unsupported result_format: {result_format}"
           )
   ```
   
   


----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] zhaoyongjie commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492443662



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       this expression is unreachable `response = self.response_400(message=f"Unsupported result_format: {result_format}")`  , because marshmallow validate method can raise exception when request is unexpect.
   
   can we move all try...catch express to marshmallow logic?




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] villebro commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492491935



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       @zhaoyongjie I've placed that backstop there to ensure so that if someone adds a new result type to the marshmallow schema but forgets to add it to the endpoint, they don't get a `None` result. Having said that, you're absolutely right that this method is extremely loaded and should not be this complex, with this type of logic preferably elsewhere (marshmallow schema, `QueryContext`/`QueryObject`). If we can make sure that there is no way of ending up at the end of this method with a `result_type` that is unsupported I'm ok with removing it. However, that probably requires moving said logic to `QueryContext`.




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] villebro commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492491935



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       @zhaoyongjie I've placed that backstop there to ensure so that if someone adds a new result type to the marshmallow schema but forgets to add it to the endpoint, they don't get a `None` result. Having said that, you're absolutely right that this method is extremely loaded and should not be this complex, with this type of logic preferably elsewhere (marshmallow schema, `QueryContext`/`QueryObject`). If we can make sure that there is no way of ending up at the end of this method with a `result_type` that is unsupported I'm ok with removing it. However, that probably requires moving said logic to `QueryContext`.




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] zhaoyongjie closed pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
zhaoyongjie closed pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977


   


----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] zhaoyongjie commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492443662



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       this expression is unreachable `response = self.response_400(message=f"Unsupported result_format: {result_format}")`  , because marshmallow validate method can raise exception when request is unexpect.
   
   can we move all try...catch express to marshmallow logic?




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] stale[bot] commented on pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
stale[bot] commented on pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#issuecomment-734494741


   This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue `.pinned` to prevent stale bot from closing the issue.
   


----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] zhaoyongjie commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492443662



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       this expression is unreachable `response = self.response_400(message=f"Unsupported result_format: {result_format}")`  , because marshmallow validate method can raise exception when request is unexpect.
   
   can we move all try...catch express to marshmallow logic?




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492182107



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       Not sure if all errors are caught by marshmallow on this. Also setting `response = None` is dangerous has it may end up has a Flask response
   
   @villebro any thought on this?




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #10977: Minor refactor, remove unreachable codes

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #10977:
URL: https://github.com/apache/incubator-superset/pull/10977#discussion_r492182107



##########
File path: superset/charts/api.py
##########
@@ -469,20 +471,21 @@ def data(self) -> Response:
             return self.response_400(
                 message=_("Request is incorrect: %(error)s", error=error.messages)
             )
+
+        # ACL control
         try:
             query_context.raise_for_access()
         except SupersetSecurityException:
             return self.response_401()
+
+        # get all query payload
         payload = query_context.get_payload()
         for query in payload:
             if query.get("error"):
                 return self.response_400(message=f"Error: {query['error']}")
-        result_format = query_context.result_format
-
-        response = self.response_400(
-            message=f"Unsupported result_format: {result_format}"
-        )
 
+        result_format = query_context.result_format
+        response = None

Review comment:
       Not sure if all errors are caught by marshmallow on this. Also setting `response = None` is dangerous has it may end up has a Flask response
   
   @villebro any thought on this?




----------------------------------------------------------------
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.

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