{"record":{"id":"1439e59938f9c896","repo":"dbt-labs/dbt-core","slug":"synthetic-relation-construction-should-not-fail","errorCode":null,"errorMessage":"synthetic relation construction should not fail: {e}","messagePattern":"synthetic relation construction should not fail: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-state/src/view_traversal.rs","lineNumber":321,"sourceCode":"    view_definitions: &mut BTreeMap<String, Arc<ViewDefinition>>,\n    queue: &mut VecDeque<Arc<dyn BaseRelation>>,\n    seen_tables: &BTreeSet<String>,\n    view_def: &Arc<ViewDefinition>,\n    sources_extractor: &dyn SourcesExtractor,\n) -> AdapterResult<()> {\n    view_definitions.insert(view_def.fqn.clone(), Arc::clone(view_def));\n    let refs = extract_referenced_tables(adapter_type, view_def, sources_extractor)?;\n    for ref_fqn in refs {\n        // `ref_fqn` is a `FullyQualifiedName` with separate catalog/schema/table\n        // identifiers. Build a synthetic `BaseRelation` from those parts so\n        // the cache key derives from `semantic_fqn()`, matching seed relations.\n        match synthetic_relation_from_parts(&ref_fqn, adapter_type) {\n            Ok(rel) => {\n                if !seen_tables.contains(&rel.semantic_fqn()) {\n                    queue.push_back(rel);\n                }\n            }\n            Err(e) => unreachable!(\"synthetic relation construction should not fail: {e}\"),\n        };\n    }\n    Ok(())\n}\n\n/// Build a synthetic `Arc<dyn BaseRelation>` from the parsed parts of a\n/// `FullyQualifiedName` so its `semantic_fqn()` round-trips to the same\n/// cache key seed relations use.\n///\n/// Returns the underlying `do_create_relation` error if construction fails,\n/// so callers can include it in diagnostics.\nfn synthetic_relation_from_parts(\n    fqn: &FullyQualifiedName,\n    adapter_type: AdapterType,\n) -> Result<Arc<dyn BaseRelation>, minijinja::Error> {\n    let q = dbt_schemas::schemas::common::ResolvedQuoting {\n        database: true,\n        schema: true,","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-state/src/view_traversal.rs#L303-L339","documentation":"During state-based view traversal, a synthetic BaseRelation is built from a ref FQN and adapter type that were already parsed successfully, so construction is expected to be infallible. If synthetic_relation_from_parts returns Err, an internal invariant is broken (e.g. an adapter type or FQN shape that the synthetic relation builder cannot handle) and the traversal panics to avoid silently skipping relations in the lineage queue.","triggerScenarios":"Calling record_and_enqueue during traverse() with a ref_fqn/adapter_type pair that synthetic_relation_from_parts rejects — e.g. an adapter type without synthetic relation support or a malformed FQN part.","commonSituations":"Running `dbt clone`/state comparisons across manifests containing nodes from an adapter that doesn't implement the synthetic-relation construction contract; corrupted or hand-edited manifest FQNs; comparing state across dbt versions where FQN shapes changed.","solutions":["Check the error text for which adapter_type/FQN part failed and add or fix support for it in synthetic_relation_from_parts.","Restrict state comparison to manifests whose nodes all come from supported adapters.","Regenerate the manifest with the current dbt version instead of reusing old state artifacts.","If the FQN is user-supplied or hand-edited, rebuild it from the node's own identifiers."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if let Err(e) = synthetic_relation_from_parts(&ref_fqn, adapter_type) {\n    log::warn!(\"skipping unconstructable synthetic relation: {e}\");\n}","typeGuard":"fn supports_synthetic_relations(adapter_type: &str) -> bool { /* whitelist of adapters implementing the contract */ }","tryCatchPattern":"match synthetic_relation_from_parts(&ref_fqn, adapter_type) {\n    Ok(rel) => queue.push_back(rel),\n    Err(e) => log::warn!(\"skipping synthetic relation for {adapter_type}: {e}\"),\n}","preventionTips":["Only compare state across manifests from adapters that support synthetic relations.","Regenerate old state artifacts with the current dbt version.","Never hand-edit manifest FQNs."],"tags":["state","lineage","relations","unreachable","rust"],"backgroundTag":"internal-invariant-violation","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"}