Open jaklan opened 2 months ago
Thanks for reporting this @jaklan !
I was able to reproduce the error you got with the files and commands below.
I have tried one more thing today - to run:
dbt run --select state:modified,package:this --state previous-artifacts
instead of:
dbt run --select state:modified --state previous-artifacts
when the removed test was only affecting an upstream package, but not the current one. Unfortunately, the result is the same.
Looks like this happens semi-frequently, we should provide a better error message in this case
@ChenyuLInx that's a "quick fix", but the real one would be to discover already during parsing that model refers to non-existing test
Is this a new bug in dbt-core?
Description
Hi, recently in one of our projects a generic test, which was still referenced by some models, was by coincidence removed.
If we run
dbt run
, we would get pretty clear error:But, if we run
dbt run --select state:modified --state previous-artifacts
(which we use by default) we get:Generally, It was not noticed during MR, because in our MR pipelines we run a mix of
dbt parse
+dbt-checkpoint
to identify only changed models and avoid compiling the full project - and that obviously doesn't cover the issues like above. However, I wonder whether such issue shouldn't be identified already during parsing?Anyway, back to the problem - when playing a bit with debugger, we can see such node:
The issue is with the
macros=[None, ...]
part - thatNone
is then retrieved asmacro_uid
and fails dictionary look-up:macro_node = self.manifest.macros[macro_uid]
.Imho the easiest solution would be to add a try-except to raise the concrete error like:
{node.name} depends on macro or test, which doesn't exist anymore
unless you want to handle it in more sophisticated way.
Environment
Which database adapter are you using with dbt?
redshift, duckdb (doesn't matter)