dbt-labs/dbt-core · info
yaml deserializes into config type
Error message
yaml deserializes into config type
What it means
A test-only `.expect()` asserting that the provided YAML successfully deserializes into the config struct type `S` (e.g. `ModelConfig`) via `dbt_jinja_utils::serde::from_yaml_raw`. If the YAML in a test case is malformed or incompatible with the config type, the test panics here instead of producing a comparison failure.
Source
Thrown at crates/dbt-parser/src/dbt_project_config.rs:1343
{
// Diagnostics are emitted through the tracing layer, so capture them with a
// test consumer rather than a status reporter.
let (test_layer, _, _, log_records) = TestLayer::new();
let subscriber = create_tracing_subcriber_with_layer(
tracing::level_filters::LevelFilter::TRACE,
test_data_layer(
1,
None,
false,
std::iter::empty(),
std::iter::once(Box::new(test_layer) as ConsumerLayer),
),
&[],
)
.expect("test tracing subscriber should be valid");
let configs: S = dbt_jinja_utils::serde::from_yaml_raw(yaml, None, false, None)
.expect("yaml deserializes into config type");
// The data layer only records events emitted within an active span, so run
// `init_project_config` inside a root span.
let result = tracing::subscriber::with_default(subscriber, || {
let _root = create_root_info_span(MockDynSpanEvent {
name: "root".to_string(),
flags: TelemetryOutputFlags::ALL,
..Default::default()
})
.entered();
init_project_config::<T, S>(
&Some(configs),
Default::default(),
None,
disallow_plus_prefix,
AdapterType::Snowflake,
)View on GitHub (pinned to 0267ce9170)
Solutions
- Fix the YAML fixture so it matches the current schema of the target config struct
- Check for recently renamed/removed config fields after upgrading and update fixtures accordingly
- Convert the expect into an assertion with the deserialization error included so failures are readable
- Validate the fixture against the struct's expected keys (+-prefixed keys under config) before running
Example fix
// before
let configs: S = from_yaml_raw(yaml, None, false, None).expect("yaml deserializes into config type");
// after
let configs: S = from_yaml_raw(yaml, None, false, None)
.unwrap_or_else(|e| panic!("fixture yaml invalid: {e}")); Defensive patterns
Strategy: validation
Validate before calling
let configs: S = match from_yaml_raw(yaml, None, false, None) {
Ok(c) => c,
Err(e) => panic!("fixture yaml invalid: {e}"),
}; Prevention
- Keep test YAML fixtures in sync with config struct schema changes
- Use unwrap_or_else with the error message for readable test failures
- Grep fixtures for renamed keys after config refactors
When it happens
Trigger: Adding or editing a test case whose YAML block contains a key or value shape that doesn't match the target config struct, so `from_yaml_raw::<S>` returns Err and the expect panics.
Common situations: Test authoring mistakes: typo'd keys, values of the wrong type, or config schema changes (renamed/removed fields) that make existing fixture YAML invalid.
Related errors
- Error message always present on ShouldBe::ButIsnt variant
- Error always present on ShouldBe::ButIsnt variant
- ProtoEnumSerde can only be derived for enums
- Should be able to serialize job labels
- test tracing subscriber should be valid
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/def3e2489b0ec88f.
Report an issue: GitHub.