dbt-labs/dbt-core · error · minijinja::Error (InvalidOperation)
Required var '{}' not found in config: Vars supplied to {} =
Error message
Required var '{}' not found in config:
Vars supplied to {} = {} What it means
Raised by `missing_var_error` when `var()` is asked for a variable that is absent from the vars configuration and no default was provided. The error embeds the requested var name, the package it was looked up in, and a pretty-printed JSON dump of all vars actually supplied, to make the mismatch obvious.
Source
Thrown at crates/dbt-jinja-vars/src/var.rs:101
if let Some(v) = keyword_default_value {
// Keyword default: var("x", default=...)
default_value = Some(v);
} else {
// Positional default: var("x", "abc")
default_value = Some(second.clone());
}
}
Ok((var_name, default_value))
}
/// Consistent missing-var error shape.
fn missing_var_error<M>(package_name: &str, var_name: &str, vars_lookup: &M) -> Error
where
M: Serialize + ?Sized,
{
Error::new(
ErrorKind::InvalidOperation,
format!(
"Required var '{}' not found in config:\nVars supplied to {} = {}",
var_name,
package_name,
serde_json::to_string_pretty(vars_lookup).unwrap()
),
)
}
/// Common handler for `has_var`.
fn call_has_var(&self, state: &State<'_, '_>, args: &[Value]) -> Result<Value, Error> {
if args.is_empty() {
return Err(Error::new(
ErrorKind::InvalidOperation,
"has_var requires 1 argument",
));
}View on GitHub (pinned to 0267ce9170)
Solutions
- Supply the var: `dbt run --vars '{"my_var": "value"}'` or add it under `vars:` in dbt_project.yml.
- Add an inline default: `{{ var('my_var', 'fallback') }}`.
- Compare your supplied vars against the JSON dump in the error message to spot spelling/package mismatches.
- Check the var is defined for the correct package namespace (package-scoped vs global vars).
Example fix
// before (Jinja)
{{ var('start_date') }}
// after
{{ var('start_date', '1970-01-01') }} <!-- or add vars: start_date: ... to dbt_project.yml --> Defensive patterns
Strategy: fallback
Validate before calling
{% if not has_var('my_var') %}{{ exceptions.raise_compiler_error('my_var is required; supply via --vars') }}{% endif %} Try / catch
{{ var('my_var', 'default_value') }} // graceful fallback instead of hard error Prevention
- Define all required vars in dbt_project.yml vars: or pass --vars on every invocation
- Use has_var() to branch before var()
- Keep var names in one place (a macro) to avoid typos and package mismatches
When it happens
Trigger: `{{ var('my_var') }}` where `my_var` is not in the supplied vars dict for the package and no `default=` kwarg was passed. The lookup map (`vars_lookup`) is serialized into the message via serde_json.
Common situations: `dbt run` without `--vars '{"my_var": ...}'` or `vars:` in dbt_project.yml; a typo between the Jinja call and the var definition; a var defined in one package but referenced from another package's context; renaming a var without updating all references.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- 'env_var': environment variable '{var}' not found
- argument 'name' to var() has incompatible type; value is not
- describe_dynamic_table is not supported by the {} adapter
- describe_interactive_table is not supported by the {} adapte
- The 'statement' result named '{name}' has already been loade
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/6d61ac7afe3541e6.
Report an issue: GitHub.