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

  1. Supply the var: `dbt run --vars '{"my_var": "value"}'` or add it under `vars:` in dbt_project.yml.
  2. Add an inline default: `{{ var('my_var', 'fallback') }}`.
  3. Compare your supplied vars against the JSON dump in the error message to spot spelling/package mismatches.
  4. 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

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


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/6d61ac7afe3541e6. Report an issue: GitHub.