-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: setting specific exceptions common/query_context.py #10942
fix: setting specific exceptions common/query_context.py #10942
Conversation
superset/common/query_context.py
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem - I'll bring it back.
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good!
I think Personally I'd recommend adding 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! |
@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
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. |
- added broad exception in `get_df_payload` method
807a222
to
c406953
Compare
…l_access/dashboard_by_id_endpoints * upstream/master: (29 commits) fix(presto): default unknown types to string type (apache#10753) feat(row-level-security): add base filter type and filter grouping (apache#10946) docs: add gallery screenshot & link in README (apache#10988) docs: add a "Gallery" page (apache#10968) build: add PR lint action (apache#10990) adding filters back that caused issues (apache#10989) chore: selectors refactor in SQLLab test suite (Cypress) (apache#10944) ESLint: Remove ts-ignore comments (apache#10933) style: fix checkbox color (apache#10970) fix: changed disabled rules in datasets module (apache#10979) fix: update the time filter for 'Last Year' option in explore (apache#10829) fix: use nullpool even for user lookup in the celery (apache#10938) Allow empty observations in alerting (apache#10939) fix: re-enabling several globally disabled lint rules (apache#10957) fix: setting specific exceptions common/query_context.py (apache#10942) Pylint disabled rule `pointless-string-statement` is not raising warining anymore - removing (apache#10975) fix: pylint disabled rules in dashboard/api.py (apache#10976) fix: removed disabled lint rule `too-many-locals` in connectors/base/models.py (apache#10958) ESLint: Re-enable rule no-access-state-in-setstate (apache#10870) fix: simply is_adhoc_metric (apache#10964) ...
* Specified an exceptions in reading cache in `get_df_payload()` method * Reverted change after review: - added broad exception in `get_df_payload` method
SUMMARY
Exceptions which may appear in
get_df_payload()
method may be more precise:KeyError
as specific Exception which can be thrownbroad-except
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
ADDITIONAL INFORMATION