Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#16448·dbt-core

[v2 Bug] Unit test `overrides.vars` hides project vars from the model

Author: hrkhCreated Sep 25, 2026Updated Oct 1, 2026
Labelstype:bugstatus:triagearea:adaptersengine:v2triagebugbigqueryv2

Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?

  • I believe this is a new bug in dbt v2.x
  • I have searched the existing issues and could not find a duplicate

Current Behavior

When a unit test sets overrides.vars, project vars are no longer available while the model is rendered. Any var() call that isn't in the override fails:

[error] [JinjaError (dbt1501)]: Failed to render SQL invalid operation: Required var 'max_ts' not found in config:
Vars supplied to <Configuration> = {}

The var in the override is unrelated to the one that fails. Removing overrides.vars makes the test pass, and so does passing the var on the CLI with --vars.

Expected Behavior

Override vars are applied on top of project vars, as in dbt 1.x. The same project passes on dbt 1.12.4.

Steps To Reproduce

dbt_project.yml:

yaml
name: repro
version: "1.0.0"
profile: repro
vars:
  max_ts: "9999-12-31 00:00:00"

models/my_model.sql:

sql
select
  1 as id,
  '{{ var("max_ts") }}' as max_ts

models/my_model.yml:

yaml
unit_tests:
  - name: test_my_model
    model: my_model
    overrides:
      vars:
        unrelated_var: "x"
    given: []
    expect:
      rows:
        - {id: 1, max_ts: "9999-12-31 00:00:00"}

Then run dbt test --select test_my_model.

Run Result
v2, as above error above
v2, with --vars '{"max_ts": "9999-12-31 00:00:00"}' pass
v2, without overrides pass
dbt 1.12.4, as above pass

Relevant log output

bash

Environment

markdown
- dbt v2 2.0.5 (macOS, arm64)
- Also seen on dbt platform with the v2 Stable track
- dbt 1.12.4 with dbt-bigquery 1.12.0 for comparison

Which database adapter are you using?

bigquery

Is this a discrepancy vs. dbt 1.x?

  • Yes — this works in dbt 1.x but not in dbt v2.x

Additional Context

We see the same thing whether the project vars live in dbt_project.yml or in vars.yml.

Source: dbt-labs/dbt-core

View original on GitHubView discussion on GitHub