dbt-labs/dbt-core · error

DbtQuoting -> QuotingConfig conversion

Error message

DbtQuoting -> QuotingConfig conversion

What it means

Panic "DbtQuoting -> QuotingConfig conversion" occurs in NodeBaseAttributes for models when `model_config.quoting.try_into::<QuotingConfig>()` fails. TryFrom<DbtQuoting> for QuotingConfig only fails when the quoting struct contains values that cannot be represented, making this an internal conversion invariant.

Source

Thrown at crates/dbt-parser/src/resolve/resolve_models.rs:879

                            .filter_map(|c| c.to.as_ref())
                            .filter_map(|spanned| {
                                parse_source_from_constraint(spanned).map(|(src, tbl)| {
                                    DbtSourceWrapper {
                                        source: vec![src, tbl],
                                        location: Some(CodeLocationWithFile::from(
                                            spanned.span().clone(),
                                        )),
                                    }
                                })
                            }),
                    )
                    .collect(),
                metrics,
                materialized,
                quoting: model_config
                    .quoting
                    .try_into()
                    .expect("DbtQuoting -> QuotingConfig conversion"),
                quoting_ignore_case: model_config.quoting.snowflake_ignore_case.unwrap_or(false),
                static_analysis_off_reason: (*static_analysis == StaticAnalysisKind::Off)
                    .then_some(StaticAnalysisOffReason::ConfiguredOff),
                static_analysis,
                unrendered_config,
            },
            __model_attr__: DbtModelAttr {
                introspection: if sql_file_info.this {
                    IntrospectionKind::This
                } else {
                    IntrospectionKind::None
                },
                version: maybe_version.map(|v| v.into()),
                latest_version: maybe_latest_version.map(|v| v.into()),
                constraints: model_constraints,
                deprecation_date,
                primary_key: vec![], // applied in resolver.rs -> primary_key_inference.rs
                time_spine,

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Inspect the TryFrom<DbtQuoting> for QuotingConfig impl and handle the newly added/unset field that causes the Err.
  2. Unset or normalize the offending quoting key in the model's config before conversion.
  3. Replace expect with error propagation that reports the model name and quoting value.

Example fix

// before
quoting: model_config.quoting.try_into().expect("DbtQuoting -> QuotingConfig conversion"),
// after
quoting: model_config.quoting.clone().try_into().unwrap_or_default(),
Defensive patterns

Strategy: validation

Validate before calling

// verify quoting config round-trips before building nodes
let qc: Result<QuotingConfig, _> = model_config.quoting.clone().try_into();
if qc.is_err() { eprintln!("unconvertible quoting: {:?}", model_config.quoting); }

Type guard

fn convertible_quoting(q: &DbtQuoting) -> bool { QuotingConfig::try_from(q.clone()).is_ok() }

Try / catch

let quoting: QuotingConfig = model_config.quoting.clone().try_into().unwrap_or_default();

Prevention

When it happens

Trigger: Building NodeBaseAttributes from a model whose config.quoting holds an unsupported/incompatible quoting field value — typically after adding a new field to DbtQuoting without updating the TryFrom impl.

Common situations: Config rendered from YAML with unusual quoting keys (e.g., database quoting set unexpectedly) or a dbt-core version bump adding quoting fields the parser's conversion doesn't handle.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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