dbt state:modified bug: comparing wrong artifacts
Fixes dbt state selection picking the wrong models by pointing --state at the correct prior-run artifacts directory and verifying the manifest timestamp. Use when state:modified selects too many, too few, or the wrong models. Not for state selection that works but is slow.
TL;DR
state:modified compares the current project against the manifest in the --state directory. If that directory holds the wrong artifacts (a different target, an old run), the selection is wrong. Point --state at the right prior manifest, verify with dbt ls, then run.
Error
dbt state:modified bug: comparing wrong artifactsSteps
- Check what is in your
--statedirectory: look at themanifest.jsontimestamp and the target it was built from. Expected: you confirm whether it matches the baseline you intended. - Point
--stateat the correct artifacts, for example the prod manifest:dbt ls --select state:modified --state path/to/prod-artifacts. Expected: the command uses the intended baseline. - Inspect the selection: does it match the models you actually changed? Expected: the selected set looks right.
- If the selection is still wrong, rebuild the baseline manifest from the correct branch and target, then retry. Expected: a fresh, trustworthy baseline.
- Run your command with the corrected
--statepath. Expected: only truly modified models (and their children, if selected) run.
When to use
state:modifiedselects models you did not change, or misses ones you did.- You just changed how CI stores or fetches artifacts.
When not to use
- State selection works but is slow (an artifact-size problem).
- You want all models (drop the state selector entirely).
Tool compatibility
- dbt Core 1.0 and later, all adapters. State selectors are adapter-independent.
Variant phrasings
state:modified selects everything on every run
The baseline manifest is stale or from a different target; every node looks modified.
state:new misses a new model
The baseline is newer than you think, or the model was not in the baseline manifest.
Why it happens
State comparison is only as good as the baseline. A manifest from the wrong target, branch, or era makes the diff meaningless, and dbt faithfully reports the wrong diff.
Edge cases
- Manifests are not portable across dbt versions; a baseline built with a different core version can misbehave.
- Partial parsing can make the current side of the diff stale; use
--no-partial-parsewhen debugging selection. - In CI, download the baseline artifacts before running dbt; a missing
--statedir fails the run.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_lBt6wwQ1lF54KFGKyCQVEQ