Medium severitycompilation
Power BI Refresh Error:
ProjectVariableNotFound
What does this error mean?
A dbt model, macro, or hook used the var() function to reference a project variable that was not defined in dbt_project.yml and was not passed via the --vars flag, causing a compilation error.
Common causes
- 1A new model was added using var() but the variable was not added to the vars section of dbt_project.yml
- 2The variable was defined in a package's dbt_project.yml but the consuming project does not define it, and no default is provided
- 3The variable name in the var() call has a typo compared to the key in dbt_project.yml
- 4A --vars override in a CI/CD job specifies a different variable name than what the model expects
How to fix it
- 1Step 1: Identify the variable name from the compilation error message.
- 2Step 2: Add the variable to the vars section of dbt_project.yml with a sensible default value.
- 3Step 3: Alternatively, provide a default directly in the code: var('my_var', 'default_value').
- 4Step 4: If the variable should differ per environment, configure it as a dbt Cloud environment variable using env_var() or via the --vars flag in the job definition.
- 5Step 5: Run 'dbt compile' to confirm the variable resolves correctly.