Data & Analytics
dbt parse-time graph writes can spoil a run hook’s cache
Check parse and run state when a dbt v2 project or package uses graph-based Jinja caches.
November 11, 2026
A dbt project parses, but a package’s run-scoped values come back empty. In a dbt v2 report, a reader macro calls graph.setdefault during parse and leaves an empty key. The on-run-start initializer later uses setdefault too, sees that key and skips its defaults. The reporter says the same project behaves correctly on dbt-core 1.12.6.
Isolate the phase boundary
Record what the package expects to exist before parsing, after parsing and at the start of execution. Test a minimal project with one cache reader and the hook. dbt’s hook guidance places on-run-start at the beginning of supported commands, but a hook cannot initialize a value if its code treats a parse-created empty object as complete.
Use the compiled artifacts and logs to distinguish three cases: the hook did not run, the hook ran but skipped initialization, or the reader used the wrong key. The Jinja context reference documents graph and execute; it does not promise that arbitrary mutation of graph is a durable package storage API.
Protect the production run
Pin known-good versions while checking a package fix or upstream resolution. If you own the macro, keep parse-time reads free of writes and make run initialization explicit rather than relying on key absence. Regression-test the same command under both engines with a value that would fail visibly if the cache stayed empty.
Adovo’s view
The dangerous state is the one a run inherits without knowing it. A parse should describe work; a run should own its mutable state. Make that boundary visible in tests before upgrading a shared data platform.
