Skip to content
Latchkey

dbt "Compilation Error" in tests in CI

dbt failed at compile time, before running any test, because a model or test references something it cannot resolve: an undefined ref, a missing macro, or a column that does not exist in the manifest.

What this error means

A dbt test or dbt build step fails with "Compilation Error in test ..." naming an undefined ref, macro, or column, and no tests actually run.

dbt
Compilation Error in test not_null_orders_customer_id (models/marts/orders.yml)
  Model 'model.shop.orders' depends on a node named 'stg_customers' which
  was not found

Common causes

An undefined ref or source

A test or model refs a node that does not exist in the project, or a source that is not declared, so compilation fails.

A missing macro or package

A test uses a macro from a package (for example dbt_utils) that was not installed with dbt deps in CI.

How to fix it

Install packages and validate the graph

  1. Run dbt deps so package macros are available.
  2. Run dbt parse or dbt compile to surface graph errors early.
  3. Fix the undefined ref, source, or column the error names.
.github/workflows/ci.yml
- run: dbt deps
- run: dbt compile   # fail fast on compilation errors before tests

Correct the reference

Point the ref at a real model name, declare the missing source, or fix the column name in the test config.

How to prevent it

  • Run dbt deps before compile in CI.
  • Add dbt compile as an early fail-fast step.
  • Keep refs, sources, and column names in sync with the models.

Related guides

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