{"record":{"id":"d8a60f16826cf5ad","repo":"dbt-labs/dbt-core","slug":"failed-to-serialize-object","errorCode":null,"errorMessage":"Failed to serialize object","messagePattern":"Failed to serialize object","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/phases/run/run_node_context.rs","lineNumber":128,"sourceCode":"    let model = node.serialize();\n    let common_attr = node.common();\n    let base_attr = node.base();\n    let resource_type = node.resource_type();\n    // Create a relation for 'this' using config values\n    let this_relation = dbt_adapter::relation::RelationObject::new(Arc::from(\n        dbt_adapter::relation::do_create_relation(\n            adapter_type,\n            base_attr.database.clone(),\n            base_attr.schema.clone(),\n            Some(base_attr.alias.clone()),\n            None,\n            base_attr.quoting,\n        )\n        .unwrap(),\n    ))\n    .into_value();\n\n    let config_yml = dbt_yaml::to_value(deprecated_config).expect(\"Failed to serialize object\");\n\n    // `ModelConfig`/`SeedConfig`/`SnapshotConfig` serialize hooks under the underscored\n    // name; `FunctionConfig` doubles as its own manifest type and so uses dbt-core's\n    // hyphenated key. Accept either.\n    let hooks_of = |underscored: &str, hyphenated: &str| {\n        config_yml\n            .get(underscored)\n            .or_else(|| config_yml.get(hyphenated))\n    };\n\n    let pre_hooks = hooks_of(\"pre_hook\", \"pre-hook\").map(|pre_hook| {\n        let values: Vec<HookConfig> = match pre_hook {\n            YmlValue::String(_, _) | YmlValue::Mapping(_, _) => {\n                parse_hook_item(pre_hook).into_iter().collect()\n            }\n            YmlValue::Sequence(arr, _) => arr.iter().filter_map(parse_hook_item).collect(),\n            YmlValue::Null(_) => vec![],\n            _ => {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/phases/run/run_node_context.rs#L110-L146","documentation":"This panic comes from `serde_yaml::to_value` (dbt_yaml) while serializing the node's deprecated raw config into a YAML value during run-phase node context building. Serialization can only fail here if the config contains non-string map keys or other YAML-incompatible structures, which indicates an invariant violation in how the config was constructed upstream rather than bad user YAML. The library treats this as unrecoverable and panics via `.expect`.","triggerScenarios":"`build_model_context_fields` calls `dbt_yaml::to_value(deprecated_config)` and the `DeprecatedConfig`/config value contains keys or values that cannot round-trip into a YAML mapping (e.g. non-string map keys produced by templating, or a poisoned config built by an adapter hook).","commonSituations":"Custom materializations or adapters injecting config entries with unexpected key types; internal dbt version mismatches where `ModelConfig`/`SeedConfig`/`SnapshotConfig`/`FunctionConfig` hooks were stored under a key type the serializer rejects; exotic user configs surviving Jinja rendering as non-scalar keys.","solutions":["Reproduce with the failing model/seed/snapshot and inspect the rendered `config` dict for non-string or exotic map keys","Update to the latest dbt-fusion/dbt-jinja-utils version — config coercion fixes often land here","Check the custom adapter/materialization for code that inserts into node config with non-String keys","Capture RUST_BACKTRACE=1 output and file a bug with the model SQL and config block"],"exampleFix":"// before (internal, illustrative)\nlet config_yml = dbt_yaml::to_value(deprecated_config).expect(\"Failed to serialize object\");\n// after\nlet config_yml = dbt_yaml::to_value(&deprecated_config)\n    .map_err(|e| ErrFatal.load_error(format!(\"failed to serialize node config: {e}\")))?;","handlingStrategy":"validation","validationCode":"// sanity-check config keys before serializing\nfn serializable_config(cfg: &serde_json::Value) -> bool {\n    cfg.as_object().map(|m| m.keys().all(|k| !k.is_empty())).unwrap_or(false)\n}\nif !serializable_config(&deprecated_config) { return Err(...); }","typeGuard":null,"tryCatchPattern":"// replace .expect with error propagation\nlet config_yml = dbt_yaml::to_value(&deprecated_config)\n    .map_err(|e| format!(\"config serialization failed: {e}\"))?;","preventionTips":["Keep node config map keys as strings after Jinja rendering","Keep adapter/parser crates on matching versions","Reproduce with RUST_BACKTRACE=1 and report non-serializable configs upstream"],"tags":["serialization","yaml","config","panic"],"backgroundTag":"json-serialization-failed","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}