Skip to content
Latchkey

dbt "Compilation Error ... depends on a node named ... which was not found" in CI

dbt parsed your project and built the DAG, but a ref() or source() points to a node that is not in the graph. dbt raises a Compilation Error naming the model and the missing dependency.

What this error means

dbt compile or dbt run fails with "Compilation Error in model X ... depends on a node named 'Y' which was not found". The referenced model name is misspelled, missing, or excluded by selection.

dbt
Compilation Error in model orders (models/marts/orders.sql)
  depends on a node named 'stg_payments' which was not found

Common causes

A typo or renamed model in ref()

The string in ref('stg_payments') does not match any model file name, often after a rename that missed a reference.

The referenced model is not in the built project

The model lives in a package or path not installed/compiled in CI, or a --select filter excluded it while a dependent stayed in.

How to fix it

Correct the ref to a real model name

  1. Find the model name dbt says is missing.
  2. Confirm a .sql file or source defines exactly that name.
  3. Fix the ref()/source() string, then re-run dbt compile.
models/marts/orders.sql
-- the referenced model must exist as models/staging/stg_payments.sql
select * from {{ ref('stg_payments') }}

Install packages and avoid partial selection

Run dbt deps so package models are present, and build a consistent selection so a model is not referenced without its dependency.

Terminal
dbt deps
dbt compile

How to prevent it

  • Run dbt deps before compile so package nodes exist.
  • Update every ref() when renaming a model.
  • Use --select +model to include upstream dependencies in selective builds.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →