Fixing Safely with CI and Flags
dbt Analytics Engineering · Lesson 12 of 17 · 1:26:26
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the dbt Analytics Engineering Certification exam. In this lesson: fixing a model in development on a branch, CI jobs with state:modified+ and deferral to production, flags in the CLI, environment variables, and the project file, and behavior change flags. Includes three original practice questions, with Orchardline Meal Kits, a fictional meal-kit company, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
A fix that broke Friday
On Friday, a bad fix to Orchardline's revenue mart reached the finance dashboards, because it was written and tested directly against production. From now on, the team wants every fix built and tested on its own branch, then checked automatically before it is merged. This lesson covers fixing in development, continuous integration, flags, and behavior changes.
Fixing in development
A fix starts on a new Git branch, never directly on the main branch that production runs from. In development, your profile points to a development target, with its own schema, so your builds never touch the production tables. First reproduce the failure, by building the failing model alone, then change the code, and build the model with everything downstream of it, with a plus sign after its name. dbt build runs the tests along with the models, so the fix is tested before anyone reviews it, and a new test that would have caught the bug keeps it from coming back. Then commit the change, push the branch, and open a pull request.
Continuous integration
When a pull request is opened, a continuous integration job, or CI job, builds the change automatically, and runs again on every new commit pushed to it. In the dbt platform, the default CI command is dbt build with the state modified plus selector, which builds only the new or changed models, and everything downstream. Unchanged parents are not rebuilt: the job defers to production, and reads them from there, which keeps the job fast and cheap. The job builds into a temporary schema, named after the job and the pull request, and dbt drops it when the pull request is merged or closed. The result is reported on the pull request, so reviewers merge only a change that built and passed its tests.
Flags
Flags, also called global configs, change how dbt runs, not what it runs, like failing fast at the first error, or treating warnings as errors. You can set a flag in three places: a command line option for one invocation, an environment variable for one environment, like CI or production, or the flags block of dbt project dot yml, as a default for everyone. The most specific setting wins: the command line beats the environment variable, which beats the project file. In dbt one point eleven, flag environment variables use the D B T engine prefix.
Behavior changes
A behavior change is a deliberate change in a new dbt version, where the same code gives a different result, like a new validation error. dbt puts each one behind a behavior change flag, which can only be set in the flags block of the project file, so it goes through a pull request, like any code change. A new flag is first introduced as disabled, which keeps the old behavior, until the project opts in. Later, the flag matures, and the new behavior becomes the default: you can still keep the old one for a while, with deprecation warnings. Finally, the old behavior is removed, so plan the migration: turn the flag on in development, fix what breaks, and merge it once CI passes.
Recap
Let's recap. Fix on a branch, in your development schema, and build the model with everything downstream of it. Open a pull request, and let the CI job build the modified models in a temporary schema, deferring to production. Flags change how dbt runs, and the command line beats environment variables, which beat the project file. Behavior change flags are set only in the project file, and move from disabled, to default, to removed. So opt in on a branch, and merge once CI passes.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
A developer fixed a join in fct_orders, on a branch, in the development schema. Which command best checks the fix before the pull request?
- dbt run --select fct_orders
- dbt test --select fct_orders
- dbt build --target prod --select fct_orders+
- dbt build --select fct_orders+
Show the answer
dbt build --select fct_orders+
Dbt build runs the fixed model, everything downstream of it, and their tests, in the development schema. “dbt run --select fct_orders” is wrong, since dbt run builds the model, but runs no test. “dbt test --select fct_orders” is wrong, since dbt test only checks the table as it was, without building the fix. And “dbt build --target prod --select fct_orders+” is wrong, since the production target would change production before any review.
The project file sets fail_fast: true in its flags block, and the CI job runs dbt build --no-fail-fast. What happens at the first error in CI?
- The run stops, since the project file sets the default
- The run continues, since the command line option wins
- dbt raises an error, since the two settings conflict
- The run stops, unless an environment variable is set
Show the answer
The run continues, since the command line option wins
The command line option is the most specific setting, so it beats the project default for that invocation. “The run stops, since the project file sets the default” is wrong, since the project file only sets the default. “dbt raises an error, since the two settings conflict” is wrong, since dbt simply applies the most specific setting. And “The run stops, unless an environment variable is set” is wrong, since the command line already beats any environment variable.
After an upgrade, dbt shows deprecation warnings, because the project sets a matured behavior change flag to false. What should the team do?
- Silence the warnings with an environment variable
- Downgrade dbt to the previous version for good
- Set the flag to true on a branch, fix, then merge
- Pass the flag on the command line of every run
Show the answer
Set the flag to true on a branch, fix, then merge
The old behavior will be removed one day, so the team should opt in on a branch, fix what breaks, and merge once CI passes. “Silence the warnings with an environment variable” is wrong, since behavior change flags can only be set in the project file. “Downgrade dbt to the previous version for good” would only delay the migration, and miss later fixes. And “Pass the flag on the command line of every run” is wrong, since these flags cannot be set on the command line.