{"record":{"id":"b7d334b8a4ce79f4","repo":"BoundaryML/baml","slug":"no-tracer-found","errorCode":null,"errorMessage":"No tracer found","messagePattern":"No tracer found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/lib.rs","lineNumber":224,"sourceCode":"                }\n            }\n            // Config changed, clear all and insert new\n            self.tracers.clear();\n            let new_tracer = Arc::new(\n                BamlTracer::new(None, filtered.clone().into_iter())\n                    .expect(\"Failed to create BamlTracer\"),\n            );\n            self.tracers.insert(key, new_tracer.clone());\n            new_tracer\n        }\n    }\n\n    /// Get the current tracer (the only one in the map, if any).\n    pub fn get_tracer(&self) -> Arc<BamlTracer> {\n        #[cfg(target_arch = \"wasm32\")]\n        {\n            let tracers = self.tracers.lock().unwrap();\n            tracers.values().next().expect(\"No tracer found\").clone()\n        }\n        #[cfg(not(target_arch = \"wasm32\"))]\n        {\n            self.tracers.iter().next().expect(\"No tracer found\").clone()\n        }\n    }\n}\n\ncfg_if::cfg_if!(\n    if #[cfg(target_arch = \"wasm32\")] {\n        type DashMap<K, V> = std::sync::Arc<std::sync::Mutex<std::collections::HashMap<K, V>>>;\n    } else {\n        use dashmap::DashMap;\n    }\n);\n\n/// RAII guard that ensures both TraceEvent::new_function_end and finish_baml_call\n/// are properly called, even if the function returns early due to an error.","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/lib.rs#L206-L242","documentation":"get_tracer assumes the internal tracers map always holds at least one tracer and unwraps its first entry on the wasm32 target. If the map is empty (no tracer was ever created, or all were cleared), expect panics with 'No tracer found'. It is a guard against an invariant violation in tracer lifecycle management.","triggerScenarios":"Calling BamlRuntime::get_tracer on wasm32 when the tracers mutex map contains no entries — i.e. get_or_create_tracer was never called or the map was cleared by a config-change path that failed before inserting a new tracer.","commonSituations":"Accessing the tracer before runtime initialization completes; a prior get_or_create_tracer panicked and left the map empty; single-page-app reloads that recreate runtime state out of order.","solutions":["Ensure get_or_create_tracer is called (and succeeds) before any get_tracer call","Return an Option/Result from get_tracer instead of expect so callers can handle the empty case","Check application initialization order so the runtime is fully constructed before tracing APIs are used","Fix any failing tracer creation path that clears the map but fails to insert a replacement"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// wasm caller check before use\nif tracers_len(tracer_map) == 0 {\n    tracer = get_or_create_tracer(config);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always initialize the runtime (get_or_create_tracer) before tracing calls","Never leave the tracers map empty after a config-change clear","Use a Result-returning accessor in wrapper code"],"tags":["rust","wasm","tracing","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}