-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Bug] return in finally can swallow exceptions #10904
Comments
Thanks for reporting this @iritkatriel ! I'm curious how you discovered this. Did you actually notice something behaving incorrectly? Or is this some code you noticed that could theoretically have unintended behavior? It looks to me like this code was added in #10699 which is not in dbt-core v1.8 but it slated for release in dbt-core v1.9. |
I'm doing some analysis on return/break/continue in finally blocks (how often its use is correct/incorrect in real code). So running static analysis on lots of open source code. While I'm at it, I'm filing issues when I think it's worth looking into. |
Thanks again for raising this @iritkatriel 🤩 After discussing briefly with @peterallenwebb, he affirmed that we'd be interested in refactoring this section of code (specifically the part you mentioned): Lines 88 to 100 in f7b7935
|
Is this a new bug in dbt-core?
Current Behavior
in
dbt-core/core/dbt/task/run.py
Line 100 in f7b7935
return
statement in afinally
block, which would swallow any in-flight exception.This means that if an exception other than
DbtRuntimeError
is raised from thetry
body, or any exception is raised from theexcept
: clause, it will not propagate on as expected.See also https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.
Expected Behavior
Refactor so that there is no
return
infinally
.Steps To Reproduce
NA
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
other (mention it in "Additional Context")
Additional Context
No response
The text was updated successfully, but these errors were encountered: