dbt-labs/dbt-core · info
test tracing subscriber should be valid
Error message
test tracing subscriber should be valid
What it means
A test-only `.expect()` in the `invalid_markdown_doc_reports_warning_and_continues` test in resolve_macros: a tracing subscriber composed for capturing span events must be valid. If the subscriber setup is rejected (invalid filters/layer combination or a conflicting global subscriber), the test panics before exercising the markdown-doc warning path.
Source
Thrown at crates/dbt-parser/src/resolve/resolve_macros.rs:675
#[test]
fn invalid_markdown_doc_reports_warning_and_continues() -> FsResult<()> {
let tmp_dir = tempdir().unwrap();
let base_path = tmp_dir.path().to_path_buf();
fs::create_dir_all(base_path.join("models")).unwrap();
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");
struct InvalidCase<'a> {
name: &'a str,
files: Vec<(&'a str, &'a str)>,
expected_code: ErrorCode,
expected_warning_paths: Vec<&'a str>,
}
let invalid_cases = vec![
InvalidCase {
name: "missing_endblock",
files: vec![("missing_endblock.md", "{% docs broken %}missing endblock")],
expected_code: ErrorCode::MacroSyntaxInvalid,
expected_warning_paths: vec!["models/missing_endblock.md"],
},
InvalidCase {
name: "duplicate_name",
files: vec![View on GitHub (pinned to 0267ce9170)
Solutions
- Remove conflicting global tracing subscriber setup in the test harness
- Use scoped subscribers (`tracing::subscriber::with_default`) as the test already does for events
- Validate the layer/filter arguments passed to the subscriber constructor
- Run the single test in isolation to identify subscriber conflicts
Example fix
// before
tracing::subscriber::set_global_default(subscriber).expect("test tracing subscriber should be valid");
// after
tracing::subscriber::with_default(subscriber, || {
// test body
}); Defensive patterns
Strategy: try-catch
Try / catch
tracing::subscriber::with_default(subscriber, || {
// run macro resolution assertions inside the scoped subscriber
}); Prevention
- Never install a global default subscriber in tests that also use with_default
- Keep test telemetry layers minimal and filter-valid
- Run doc-resolution tests in isolation when tracing conflicts occur
When it happens
Trigger: Running macro resolution tests where the test subscriber is rejected by the tracing registry — typically due to an invalid layer/filter configuration or another test having already installed the default subscriber.
Common situations: Running the dbt-parser test suite in parallel or under a harness that installs its own global tracing subscriber; modifying the test telemetry layer with bad filters.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- test tracing subscriber should be valid
- root overlay config builds
- Schema not found for canonical FQN: {}
- `EnterGuard` values dropped out of order. Guards returned by
- {e} {:?}
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/1428c0de72e67d75.
Report an issue: GitHub.