-
Notifications
You must be signed in to change notification settings - Fork 1.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
[CT-2427] [Feature] [Investigate] Gracefully handle failures in on-run-* hooks, and skip subsequent hooks/nodes #7387
Comments
@iknox-fa @aranke The context for this issue was a behavior change in v1.4, around whether a failing We discussed that issue at some length during a live BLG back in March (thanks @dbeatty10 @MichelleArk @emmyoop for weighing in!), and I opened the present issue (#7387) to capture the proposal. So - I have fairly high confidence in what's being proposed in this issue, as a way of providing the advantages of both the previous (pre-1.4) + the current (1.4+) behavior. If you have specific product/UX concerns, let's find time to chat! |
While the previous behavior was never explicitly documented, it's important for reenabling patterns like the one described in this article: |
@jtcohen6 Is this just for |
@jtcohen6 Would you also be able to add an acceptance criteria to the ticket? |
|
This may already be how this works. |
We aren't (Peter/Michelle) sure whether it already works like this or not. Another question is what a failure in the on-run-end hook would look like. Would it result in a fail-fast exception, or some other exception we aren't currently handling? So there is some investigation and experimentation to be done as part of the work here. |
This issue reflects that, since v1.4:
Repro case: Make a project with some models, and add this to the project file:
The expected behavior is that, if an
This is important to support use cases where users want to define custom "project checks" that run before models are built — sort of like |
Hello! We have some code that runs on the "on-run-start" hook. If this code fails to run, we would like the entire process to stop at that point. We expect the pre and post-hooks to also cause the process to fail and stop if there are any SQL errors. It would be great if this could be included, but if not, could it be made configurable? This way, everyone will be satisfied. ;) |
I believe this is already the way pre and post-hooks work. This issue is to do the same for on-run-start and on-run-end. |
Lightly editing questions from @katarinagacnik here:
@jtcohen6 what are the workarounds that you mentioned here?
|
Hi, I'm wondering any updates around this issue? We also want to stop the subsequent process when an exception is raised in the on-run-start hooks. |
I think I understood the behavior of this. I have a similar context here where I want to block users from running a dbt command without a select flag. For that I have this macro:
I added it to
But later, I realized that I needed to add another condition to my macro that only blocks certain commands (build, test, ...) as below:
After that, my macro stopped blocking the execution of dbt, although it generated a database error as @jtcohen6 showed us. If I remove my target folder and use the macro for the first time, without changing it, it works as expected. If I modify anything in the macro it changes the behavior, allowing it to run even when a compilation error occurs. Perhaps this could lead to a solution, knowing how to reproduce the error and the “normal” behavior. I'm using dbt 1.7.10 by the way. |
@vitorweiss The actual vs. expected behavior you describe here sounds like it is working the way you want when dbt does not use partial parsing, but doesn't work they way you want otherwise. WorkaroundIf so, then you can add the # dbt_project.yml
flags:
# set default for running this project -- anywhere, anytime, by anyone
partial_parse: false Other feature requestMaybe #10323 could be expanded to also cover errors in addition to warnings 🤷 Namely, always raise warnings (and errors!) in every invocation, even when partial parsing is used. |
Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#6172 |
Is this your first time submitting a feature request?
Describe the feature
As a dbt developer, I need to write a custom "preflight" check in an
on-run-start
hook, and know that if it raises an exception, the rest of the invocation (including all selected DAG nodes) will be skipped.At the same time, I don't want a failing
on-run-*
hook (including one that raises an exception) to cause dbt's invocation to terminate gracelessly, and to prevent it from writingrun_results.json
. Instead, I want a failing hook to be treated more like a failing model: handle the error, then skip downstream resources.Copying from #7045 (comment):
As far as the underlying implementation, I don't have a strong feeling that these hooks have to be actual participants in the actual dbt
graph
. It could stay a simplefor
loop, so long as we have enoughtry
handling to meet the expected behavior described above.Describe alternatives you've considered
These are both strictly worse:
on-run-end
hook would cause the entire invocation to terminate gracelessly, and dbt would not writerun_results.json
on-run-start
hook does not cause the invocation to skip subsequent nodes. This removes the possibility of usingon-run-start
hooks as custom "preflight" checks for the command, which is the use case outlined in [CT-2179] [Bug] Failing on-run-start does not stop dbt run #7045.Who will this benefit?
Users of
on-run-*
hooksAcceptance criteria
on-run-start
hook, dbt should skip all selected resources from running. This is not true right now.on-run-end
hook, dbt should still writerun_results.json
for all previous results. This is true right now, and the GAP team is counting on it remaining true.The text was updated successfully, but these errors were encountered: