dbt snapshot "missing ... unique_key" configuration error in CI
A dbt snapshot requires a unique_key to identify rows across runs, and this snapshot did not declare one. Without it dbt cannot detect which records changed, so it refuses to run the snapshot.
What this error means
dbt snapshot fails with "Runtime Error ... 'unique_key' is a required property" or "Snapshot X is missing a required configuration: unique_key".
dbt
Runtime Error
Snapshot 'orders_snapshot' (snapshots/orders_snapshot.sql) is missing a
required configuration: 'unique_key'Common causes
The snapshot config omits unique_key
The snapshot block declares a strategy but no unique_key, so dbt has no column to identify rows across runs.
A misplaced config outside the snapshot block
The unique_key is set in the wrong scope (not inside the snapshot config), so dbt does not see it for this snapshot.
How to fix it
Add unique_key to the snapshot config
- Choose the column (or columns) that uniquely identify a record.
- Set
unique_keyin the snapshot config block or YAML. - Run
dbt snapshot --select the_snapshotto confirm.
snapshots/orders_snapshot.sql
{% snapshot orders_snapshot %}
{{ config(
target_schema='snapshots',
unique_key='order_id',
strategy='timestamp',
updated_at='updated_at'
) }}
select * from {{ source('shop', 'orders') }}
{% endsnapshot %}Use a surrogate key for composite identity
If no single column is unique, build a surrogate key and use it as unique_key.
How to prevent it
- Always set unique_key on every snapshot.
- Use a surrogate key when identity spans multiple columns.
- Run
dbt snapshotin CI so config gaps surface before deploy.
Related guides
dbt "seed could not be loaded" runtime error in CIFix dbt seed load failures in CI - a CSV seed could not be loaded because of a type inference or column misma…
dbt "Database Error in model" SQL error in CIFix dbt "Database Error in model X" in CI - the compiled SQL ran against the warehouse and the database rejec…
dbt test failure (unique / not_null) fails CI with exit 1Fix a dbt data test failure (unique, not_null) in CI - the model data violated a test assertion, so dbt exits…