dbt-labs / dbt-labs/dbt

[BUG] Missing env_var in data test config produces misleading dbt1013 instead of env var error

Open
#14,499 0 comments 0 reactions 0 assignees View on GitHub
area:static-analysis engine:v2 slack status:needs-repro type:bug
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

**Reported by**: @pempey in [community Slack](https://getdbt.slack.com/archives/C088YCAB6GH/p1776109045291319)

**Describe the bug**

When a data test config uses `env_var()` referencing a non-existent environment variable (without a default), Fusion produces the misleading error `dbt1013: YAML error: data did not match any variant of untagged enum DataTests` instead of a clear "env var not found" message.

This is NOT specific to `snowflake_warehouse` — any missing `env_var()` without a default in a data test config triggers the same misleading error.

Notably, a missing `env_var()` in a **model** config correctly produces `dbt1501: Failed to eval the compiled Jinja expression ... environment variable not found`, so the data test config parsing path appears to swallow the Jinja error and fall through to a generic YAML deserialization failure.

**What version of dbt Fusion is this bug in?**
dbt-fusion 2.0.0-preview.170

**Is this a discrepancy between the dbt Fusion Engine and dbt Core?**
- [x] YES
- [ ] NO

**To Reproduce**

`dbt_project.yml`
```yaml
name: 'reprex'
profile: 'snowflake'
```

`models/my_model.sql`
```sql
select
current_date as date_month,
1 as ultimate_parent_namespace_id,
'path/to/metric' as metrics_path
```

`models/schema.yml`
```yaml
models:
- name: my_model
columns:
- name: date_month
data_tests:
- not_null:
config:
snowflake_warehouse: "{{ env_var('TEST_XL') }}"
```

Make sure `TEST_XL` is **not set**, then run:

```shell
dbt parse
```

**Fusion output (misleading)**:
```
error: dbt1013: YAML error: data did not match any variant of untagged enum DataTests
--> models/schema.yml:6:13
```

**dbt-core output (clear)**:
```
Parsing Error
Invalid test config given in models/schema.yml:
Env var required but not provided: 'TEST_XL'
```

**Setting the env var resolves**:
```shell
TEST_XL=SOME_WAREHOUSE dbt parse
# → Finished 'parse' successfully
```

**Additional context**

- Same `env_var('TEST_XL')` in a **model config** correctly produces `dbt1501: Failed to eval the compiled Jinja expression ... environment variable 'TEST_XL' not found`
- Using `env_var` with a default (`env_var('TEST_XL', 'FALLBACK')`) works fine
- Reproduction case: https://github.com/dbt-labs/scratch/tree/repro/fusion-1560-v2/repros/fusion-snowflake-warehouse-data-test

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.