High severityconfiguration
Power BI Refresh Error:
EnvironmentVariableNotSet
What does this error mean?
A dbt model, macro, or profile references an environment variable using env_var() that was not set in the dbt Cloud environment configuration, causing a compilation or runtime error.
Common causes
- 1The environment variable was set in the development environment but not in the production or staging environment
- 2A new model or macro was added that references an env_var() not yet configured in dbt Cloud
- 3The variable name in the code has a typo compared to the name configured in dbt Cloud
- 4The dbt Cloud environment was cloned from another project but environment variables were not copied
How to fix it
- 1Step 1: Read the error message — dbt names the exact environment variable that is missing.
- 2Step 2: In dbt Cloud, go to Deploy > Environments > the relevant environment > Environment Variables and add the missing variable.
- 3Step 3: If the variable is optional, provide a default in the code using env_var('MY_VAR', 'default_value').
- 4Step 4: Verify the variable name matches exactly, including case — dbt environment variable names are case-sensitive.
- 5Step 5: Re-run the job after adding the variable to confirm compilation succeeds.