dbt-labs/dbt-core · error · minijinja::Error (InvalidOperation)

config requires all arguments to be defined, but '{key}' is

Error message

config requires all arguments to be defined, but '{key}' is undefined

What it means

apply_config in the parse-phase model context rejects any config() kwarg whose value is minijinja-undefined. dbt requires every config argument to be a defined value; passing undefined would silently produce a broken config, so the key is reported explicitly (mirroring dbt Core's "Undefined is not valid" message).

Source

Thrown at crates/dbt-jinja-utils/src/phases/parse/resolve_model_context.rs:729

                start: dbt_yaml::Marker::new(
                    start_offset as usize,
                    start_line as usize,
                    start_col as usize,
                ),
                end: dbt_yaml::Marker::new(
                    end_offset as usize,
                    end_line as usize,
                    end_col as usize,
                ),
                filename: self.error_path.as_ref().map(|p| Arc::new(p.to_path_buf())),
            }
        };

        let mut mapping = dbt_yaml::Mapping::with_capacity(kwargs.len());
        for (key, value) in kwargs.into_iter() {
            if value.is_undefined() {
                // dbt Core names the key too: `at path ['alias']: Undefined is not valid`
                return Err(minijinja::Error::new(
                    minijinja::ErrorKind::InvalidOperation,
                    format!(
                        "config requires all arguments to be defined, but '{key}' is undefined"
                    ),
                ));
            }

            let value = if let Some(dyn_obj) = value.as_object()
                && let Some(pydatetime) = dyn_obj.downcast::<PyDateTime>()
            {
                dbt_yaml::to_value(pydatetime.chrono_dt())
            } else {
                dbt_yaml::to_value(value)
            }
            .map_err(|e| {
                MinijinjaError::new(
                    MinijinjaErrorKind::InvalidOperation,
                    format!("Failed to serialize config into yaml: {e}"),

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Provide a default for var(): config(alias=var('my_var', 'fallback')).
  2. Check spelling of the config key and of the variable/macro producing the value.
  3. Set the variable via dbt_project.yml vars or --vars flag in the failing environment.
  4. Guard with is defined: {% if x is defined %}{% do config(alias=x) %}{% endif %} or supply a literal fallback.

Example fix

-- before
{{ config(alias=var('custom_alias')) }}
-- after
{{ config(alias=var('custom_alias', this.identifier)) }}
Defensive patterns

Strategy: validation

Validate before calling

-- Jinja
{% set alias_val = var('custom_alias', none) %}
{% if alias_val is none %}
  {{ exceptions.raise_compiler_error("custom_alias is required for this model's config") }}
{% else %}
  {{ config(alias=alias_val) }}
{% endif %}

Try / catch

// Rust-side caller of config kwargs
match value.is_undefined() {
    true => return Err(friendly_undefined_error(key)),
    false => Ok(()),
}

Prevention

When it happens

Trigger: Calling config(...) in a model/schema file with a variable that is undefined at parse time, e.g. config(alias=var('missing_var')) or config(alias=some_undefined_macro_result).

Common situations: var() without a default for a variable not set in dbt_project.yml or --vars; referencing a macro attribute that doesn't exist; env_var lookups or conditionals that evaluate to undefined in one environment.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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