# on-run-end with failed models

**URL:** <https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790>\
**Category:** Help\
**Created:** [June 21, 2023, 12:04am UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790 "2023-06-21T00:04:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyoll](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@gyoll](https://discourse.getdbt.com/u/gyoll)\
**Post date:** [June 21, 2023, 12:04am UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/1 "2023-06-21T00:04:12Z")

</div>

## The problem I’m having

I’m using the dbt Artifacts package to collect and insert information about runs, but I’m only getting information about runs that complete. The upload process is triggered by an `on-run-end` hook in dbt\_project.yml and it looks like it’s not getting triggered when runs fail.

[In a related post](https://discourse.getdbt.com/t/post-hook-when-a-model-fails/6204/8) someone said that on-end-run hooks fire on unsuccessful models, so I’m a bit confused about what’s happening.

Is there a way to use on-run-end hooks or another method to upload information about failed runs with dbt Artifacts?

---

<div class="post-metadata">

**Author:** ![Surya](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/surya/32/3763_2.png) [@Surya](https://discourse.getdbt.com/u/Surya)\
**Post date:** [June 21, 2023, 5:36am UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/2 "2023-06-21T05:36:34Z")

</div>

@gyoll  
on-run-end hook will fire only once i.e only at the end of the following commands

- `dbt run`
- `dbt test`
- `dbt seed`
- `dbt snapshot`
- `dbt build`
- `dbt compile`
- `dbt docs generate`

even though ur run fails it will be triggered.

May i know the dbt version ur using

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [June 21, 2023, 2:33pm UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/3 "2023-06-21T14:33:14Z")

</div>

Your run can be completed without having succesful models, take the examples below

1 - If your model raises an error, the run will continue

2 - If you are using fail fast and your model raises an error, dbt will exit and your run will not complete

In the first case the on-run-end should work, in the second case it should not work

---

<div class="post-metadata">

**Author:** ![gyoll](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@gyoll](https://discourse.getdbt.com/u/gyoll)\
**Post date:** [June 21, 2023, 2:37pm UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/4 "2023-06-21T14:37:50Z")

</div>

@Surya We are running with dbt version 1.5.1 (in case it ends up being useful, we are running with dbt Artifacts version 2.4.2).

Just to be super clear about this, I’m working with dbt cloud runs here (not local jobs). So we’re running `dbt build` with a lot of tables but something fails. Then when I inspect the run details in dbt cloud I don’t see the end hooks in the logs, and I don’t see any entries in my artifacts tables. I do see the end hooks for successful runs and the run artifacts are appearing in the tables created by dbt Artifacts.

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [June 21, 2023, 2:39pm UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/5 "2023-06-21T14:39:12Z")

</div>

Can you show an example of a failed run? the logs

---

<div class="post-metadata">

**Author:** ![gyoll](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@gyoll](https://discourse.getdbt.com/u/gyoll)\
**Post date:** [June 21, 2023, 2:41pm UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/6 "2023-06-21T14:41:35Z")

</div>

@brunoszdl Thank you! We are using --fail-fast so that must be precluding the on-run-end hook. I don’t suppose there’s any kind of alternative to fire off end hooks when using --fail-fast?

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [June 21, 2023, 2:45pm UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/7 "2023-06-21T14:45:44Z")

</div>

I don’t think so, because fail fast causes dbt to exit immediately, so it does not even run the on-run-end hook

Maybe you can raise an issue in the dbt core about it, explaining your problem

> **[Issues · dbt-labs/dbt-core](https://github.com/dbt-labs/dbt-core/issues)**
>
> dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications. - Issues · dbt-labs/dbt-core

You can also talk to Gabriel [https://www.linkedin.com/in/gabriel-rangel-8bb275108/](https://www.linkedin.com/in/gabriel-rangel-8bb275108/)

He was having the exact same problem, maybe he has figured something out

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [June 28, 2023, 2:46pm UTC](https://discourse.getdbt.com/t/on-run-end-with-failed-models/8790/8 "2023-06-28T14:46:33Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
