{"record":{"id":"cb3e5047cdcee3be","repo":"dbt-labs/dbt-core","slug":"test-tracing-subscriber-should-be-valid","errorCode":null,"errorMessage":"test tracing subscriber should be valid","messagePattern":"test tracing subscriber should be valid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/dbt-parser/src/dbt_project_config.rs","lineNumber":1340,"sourceCode":"        T: ResolvableConfig<T> + PartialEq,\n        S: TypedRecursiveConfig + Into<T> + for<'de> serde::Deserialize<'de>,\n        T::PackageDefaults: Default,\n    {\n        // Diagnostics are emitted through the tracing layer, so capture them with a\n        // test consumer rather than a status reporter.\n        let (test_layer, _, _, log_records) = TestLayer::new();\n        let subscriber = create_tracing_subcriber_with_layer(\n            tracing::level_filters::LevelFilter::TRACE,\n            test_data_layer(\n                1,\n                None,\n                false,\n                std::iter::empty(),\n                std::iter::once(Box::new(test_layer) as ConsumerLayer),\n            ),\n            &[],\n        )\n        .expect(\"test tracing subscriber should be valid\");\n\n        let configs: S = dbt_jinja_utils::serde::from_yaml_raw(yaml, None, false, None)\n            .expect(\"yaml deserializes into config type\");\n\n        // The data layer only records events emitted within an active span, so run\n        // `init_project_config` inside a root span.\n        let result = tracing::subscriber::with_default(subscriber, || {\n            let _root = create_root_info_span(MockDynSpanEvent {\n                name: \"root\".to_string(),\n                flags: TelemetryOutputFlags::ALL,\n                ..Default::default()\n            })\n            .entered();\n\n            init_project_config::<T, S>(\n                &Some(configs),\n                Default::default(),\n                None,","sourceCodeStart":1322,"sourceCodeEnd":1358,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-parser/src/dbt_project_config.rs#L1322-L1358","documentation":"A test-only `.expect()` asserting that a tracing subscriber built from test layers is valid. In the dbt_project_config test helper, a subscriber is registered via `set_default`-style setup, and an invalid layer configuration (e.g. duplicate/dropped subscriber) causes this panic before the actual config assertions run.","triggerScenarios":"Running the project-config tests where `tracing::subscriber` setup rejects the composed subscriber (invalid filter or layer combination), or running tests in parallel when a global default subscriber is already installed.","commonSituations":"Developers running `cargo test -p dbt-parser` with test harnesses that install their own global tracing subscriber, causing conflicts; adding a layer with an invalid filter to the test telemetry setup.","solutions":["Ensure no other global default tracing subscriber is installed before these tests run","Use `try_set_default`/scoped `with_default` instead of a global set in test setups","Fix the layer/filter configuration passed to the subscriber builder","Run the test in isolation (`cargo test -p dbt-parser <test_name>`) to rule out subscriber conflicts"],"exampleFix":"// before\ntracing::subscriber::set_global_default(subscriber).expect(\"test tracing subscriber should be valid\");\n\n// after\ntracing::subscriber::set_default(subscriber); // scoped, no global conflict","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if tracing::subscriber::set_default(subscriber).is_none() {\n    eprintln!(\"skipping: another subscriber holds the default\");\n    return;\n}","preventionTips":["Avoid installing global default subscribers in test harnesses","Use scoped with_default for span-event capture in tests","Run tracing-dependent tests serially if conflicts appear"],"tags":["rust","tracing","testing","panic"],"backgroundTag":"invalid-state-transition","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}