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/17 17:48:51 UTC

[GitHub] [incubator-superset] kkucharc opened a new pull request #10942: fix: setting specific exceptions commands/query_context.py

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


   ### SUMMARY
   Exceptions which may appear in `get_df_payload()` method may be more precise:
   - suggested `KeyError` as  specific Exception which can be thrown
   - removed disabled pylint check: `broad-except`
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TEST PLAN
   <!--- What steps should be taken to verify the changes -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


----------------------------------------------------------------
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] kkucharc commented on pull request #10942: fix: setting specific exceptions common/query_context.py

Posted by GitBox <gi...@apache.org>.
kkucharc commented on pull request #10942:
URL: https://github.com/apache/incubator-superset/pull/10942#issuecomment-694838410


   @mistercrunch I totally agree with having broad-except, especially when we have as you said various integrations. My suggestions in the PR comes from my intuition - I can imagine there can be some RuntimeExceptions or even something more complicated memory issues, which can be neglected by broad-exception.
   
   If I may share my opinion about adding `broad-except` to global disabled rules, I would disagree, because of two reasons:
   1. probably if project will achieve big amount of broad exceptions it will be difficult and painful to come back,
   2. I'm afraid of over-use broad exception, because it's much easier to react to _any_ bad thing that may happen than think deeper how to address each error one by one. I guess also it may extend reviewing process.
   But of course you know wider context of the subject and requirements, so I am totally open to adding global `broad-except` and/or for further discussion 👍 
   
   Also if it comes to the current PR I am open to closing this PR if it may cause more harm than good. I fully agree that it might be worth to take care about all broad exceptions to get the most of them.


----------------------------------------------------------------
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] mistercrunch commented on pull request #10942: fix: setting specific exceptions common/query_context.py

Posted by GitBox <gi...@apache.org>.
mistercrunch commented on pull request #10942:
URL: https://github.com/apache/incubator-superset/pull/10942#issuecomment-694641986


   I think `broad-except` is totally ok sometimes. A clear example is with external database calls when we support multiple engines. There's almost no way to know ahead of time what any given driver will raise. DBAPI isn't prescriptive enough to enable that, and even if it were implementations may diverge from the the prescribed way. 
   
   Personally I'd recommend adding `broad-except` to the global allow-list, at list for now. 
   
   If really we wanted to push this, we could make sure to have consistent logging on broad exceptions and dig into logs to find what's actually been raised and catch the right thing and provide a better error message. But I think there's much bigger fish to catch at this time!


----------------------------------------------------------------
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] willbarrett merged pull request #10942: fix: setting specific exceptions common/query_context.py

Posted by GitBox <gi...@apache.org>.
willbarrett merged pull request #10942:
URL: https://github.com/apache/incubator-superset/pull/10942


   


----------------------------------------------------------------
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] willbarrett commented on a change in pull request #10942: fix: setting specific exceptions common/query_context.py

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



##########
File path: superset/common/query_context.py
##########
@@ -265,7 +265,7 @@ def get_df_payload(  # pylint: disable=too-many-locals,too-many-statements
             except QueryObjectValidationError as ex:
                 error_message = str(ex)
                 status = utils.QueryStatus.FAILED
-            except Exception as ex:  # pylint: disable=broad-except
+            except KeyError as ex:

Review comment:
       There is a lot that can go wrong here, as the `try` wraps the `get_query_result` method - I'd recommend leaving this one at the broad exception. Errors are intentionally swallowed and reported for this chunk of code.

##########
File path: superset/common/query_context.py
##########
@@ -228,7 +228,7 @@ def get_df_payload(  # pylint: disable=too-many-locals,too-many-statements
                     status = utils.QueryStatus.SUCCESS
                     is_loaded = True
                     stats_logger.incr("loaded_from_cache")
-                except Exception as ex:  # pylint: disable=broad-except
+                except KeyError as ex:

Review comment:
       This looks good!




----------------------------------------------------------------
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] kkucharc commented on a change in pull request #10942: fix: setting specific exceptions common/query_context.py

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



##########
File path: superset/common/query_context.py
##########
@@ -265,7 +265,7 @@ def get_df_payload(  # pylint: disable=too-many-locals,too-many-statements
             except QueryObjectValidationError as ex:
                 error_message = str(ex)
                 status = utils.QueryStatus.FAILED
-            except Exception as ex:  # pylint: disable=broad-except
+            except KeyError as ex:

Review comment:
       Sure, no problem - I'll bring it back. 




----------------------------------------------------------------
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] kkucharc commented on a change in pull request #10942: fix: setting specific exceptions common/query_context.py

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



##########
File path: superset/common/query_context.py
##########
@@ -265,7 +265,7 @@ def get_df_payload(  # pylint: disable=too-many-locals,too-many-statements
             except QueryObjectValidationError as ex:
                 error_message = str(ex)
                 status = utils.QueryStatus.FAILED
-            except Exception as ex:  # pylint: disable=broad-except
+            except KeyError as ex:

Review comment:
       Sure, no problem - I'll bring it back. 




----------------------------------------------------------------
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] willbarrett merged pull request #10942: fix: setting specific exceptions common/query_context.py

Posted by GitBox <gi...@apache.org>.
willbarrett merged pull request #10942:
URL: https://github.com/apache/incubator-superset/pull/10942


   


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