{"record":{"id":"97a08dcc38851978","repo":"dbt-labs/dbt-core","slug":"parent-span-must-have-a-spanstartinfo-record-in-it","errorCode":null,"errorMessage":"Parent span must have a SpanStartInfo record in its extensions","messagePattern":"Parent span must have a SpanStartInfo record in its extensions","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-tracing/src/layers/data_layer.rs","lineNumber":978,"sourceCode":"        return None;\n    };\n\n    loop {\n        // Create a block scope to limit the borrow of parent extensions\n        {\n            let parent_ext = parent.extensions();\n            let parent_span_filter_mask = parent_ext\n                .get::<FilterMask>()\n                .copied()\n                .unwrap_or_else(FilterMask::empty);\n\n            // Check if this parent span was filtered out for this consumer\n            if !parent_span_filter_mask.is_filtered(index) {\n                // Found an unfiltered parent span for this consumer. Extract its span ID\n                if let Some(parent_span_record) = parent_ext.get::<DLSpanStartInfo>() {\n                    return Some(parent_span_record.0.span_id);\n                } else {\n                    unreachable!(\"Parent span must have a SpanStartInfo record in its extensions\");\n                }\n            }\n        }\n\n        let Some(grand_parent) = parent.parent() else {\n            // No parent span, so no active parent span ID\n            return None;\n        };\n\n        parent = grand_parent;\n    }\n}\n\n#[cfg(any(test, feature = \"test-utils\"))]\npub fn get_span_start_info_from_span(\n    span: &SpanRef<'_, impl Subscriber + for<'lookup> LookupSpan<'lookup>>,\n) -> Option<SpanStartInfo> {\n    let span_ext = span.extensions();","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-tracing/src/layers/data_layer.rs#L960-L996","documentation":"This is an internal invariant panic in dbt-tracing's span-id lookup. When a child span or event has an unfiltered parent span, the parent's extensions must contain a DLSpanStartInfo record (inserted at span creation); if it does not, the layer's internal bookkeeping is broken, so the code calls unreachable!. Reaching this means a SpanStartInfo was never inserted or was removed from a live parent span's extensions.","triggerScenarios":"Calling on_new_span, on_close, or on_event where the parent span passed the consumer's filter mask but lacks a DLSpanStartInfo extension record in its extensions.","commonSituations":"Custom tracing layers or spans created outside the data layer's on_new_span path; manual extension manipulation; version mismatches where span creation no longer stores DLSpanStartInfo; spans whose extensions were cleared mid-flight.","solutions":["Verify all spans pass through the data layer's on_new_span so DLSpanStartInfo is inserted into extensions","Check for custom layers that strip or replace span extensions","Ensure the parent span belongs to the same tracing registry/dispatch and is not a synthetic or foreign span","Update dbt-tracing and report a bug with a reproducer if the invariant still breaks"],"exampleFix":"// before (workaround is not direct; guard at call site)\nlet span_id = lookup_filtered_parent_span_id(parent, mask);\n// after (defensive handling instead of unreachable)\nif let Some(rec) = parent_ext.get::<DLSpanStartInfo>() {\n    Some(rec.0.span_id)\n} else {\n    tracing::warn!(\"parent span missing DLSpanStartInfo; skipping parent id\");\n    None\n}","handlingStrategy":"validation","validationCode":"fn parent_has_span_info(parent: &tracing::span::Span) -> bool {\n    parent.extensions().get::<DLSpanStartInfo>().is_some()\n}","typeGuard":"if parent.extensions().get::<DLSpanStartInfo>().is_some() { /* safe to lookup */ }","tryCatchPattern":"// panic is not catchable in normal flow; guard before:\nlet span_id = parent_has_span_info(parent)\n    .then(|| lookup_filtered_parent_span_id(parent, mask))\n    .flatten();","preventionTips":["Never create spans that bypass the data layer's on_new_span","Do not strip extensions from live spans in custom layers","Keep dbt-tracing versions consistent across the workspace","Add a debug assertion in tests that every active parent span has DLSpanStartInfo"],"tags":["tracing","invariant","panic","internal"],"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"}