dbt-labs/dbt-core · error · minijinja::Error::SerdeDeserializeError

get_view_options: Failed to deserialize config: {e}

Error message

get_view_options: Failed to deserialize config: {e}

What it means

get_view_options() converts its `config` argument from a minijinja Value into a ModelConfig struct via serde. If the Value does not conform to ModelConfig (unexpected field types, invalid enum values, wrong nesting), deserialization fails and this SerdeDeserializeError is raised naming get_view_options and the serde detail. It means the config object handed to the macro is not a valid ModelConfig.

Source

Thrown at crates/dbt-adapter/src/adapter/mod.rs:2143

        }
    }

    #[tracing::instrument(skip(self, state), level = "trace")]
    pub fn get_view_options(
        &self,
        state: &State,
        args: &[Value],
    ) -> Result<Value, minijinja::Error> {
        match &self.inner {
            Typed { adapter, .. } => {
                let iter = ArgsIter::new("get_view_options", &["config", "node"], args);
                let config_val = iter.next_arg::<&Value>()?;
                let node_val = iter.next_arg::<&Value>()?;
                iter.finish()?;

                let config = minijinja_value_to_typed_struct::<ModelConfig>(config_val.clone())
                    .map_err(|e| {
                        minijinja::Error::new(
                            minijinja::ErrorKind::SerdeDeserializeError,
                            format!("get_view_options: Failed to deserialize config: {e}"),
                        )
                    })?;
                let node = minijinja_value_to_typed_struct::<InternalDbtNodeWrapper>(
                    node_val.clone(),
                )
                .map_err(|e| {
                    minijinja::Error::new(
                        minijinja::ErrorKind::SerdeDeserializeError,
                        format!(
                            "get_view_options: Failed to deserialize InternalDbtNodeWrapper: {e}"
                        ),
                    )
                })?;

                let inner_node = node.as_internal_node();
                let options = adapter.get_view_options(state, config, inner_node.common())?;

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Read the serde detail after the message to identify the offending config field.
  2. Pass `config.model` (the model's config object) rather than arbitrary dicts.
  3. Correct the type/value of the reported field in the model's config block (e.g. fix materialized, tags, or contract values).
  4. Align custom macro code with the ModelConfig struct fields expected by this adapter version.
  5. If a new config key is needed, it must be added to ModelConfig or be tolerated (unknown fields ignored) — check struct attributes.

Example fix

// before
{% do adapter.get_view_options({'materalized': 'view'}, model) %}

// after
{% do adapter.get_view_options(config.model, model) %}
Defensive patterns

Strategy: validation

Validate before calling

{% if config.model is mapping and config.model.get('materialized') is defined %}
  {% do adapter.get_view_options(config.model, model) %}
{% endif %}

Try / catch

{% set opts = adapter.get_view_options(config.model, model) %} wrapped in a Jinja try/except if available, falling back to {} on SerdeDeserializeError

Prevention

When it happens

Trigger: Calling adapter.get_view_options(config, node) where config is a plain dict with fields that do not map to ModelConfig (e.g. materialization string not a known variant, wrong types for fields like tags or on_schema_change), or config is a non-object value.

Common situations: Custom view materializations passing config.model but ModelConfig schema expecting different field names/types; typos in config keys; version drift between the YAML/config schema and the Rust ModelConfig struct.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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