{"record":{"id":"7dd357e53052f076","repo":"BoundaryML/baml","slug":"function-log-expected-to-be-present-no-functionstart-event","errorCode":null,"errorMessage":"Function log expected to be present (no FunctionStart event?). Did you forget to track_function()?","messagePattern":"Function log expected to be present \\(no FunctionStart event\\?\\)\\. Did you forget to track_function\\(\\)\\?","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/tracingv2/storage/storage.rs","lineNumber":545,"sourceCode":"        // Manually increment the global reference count\n        BAML_TRACER.lock().unwrap().inc_ref(&id);\n        let instance_id = Uuid::new_v4().to_string();\n\n        Self {\n            id,\n            inner: None,\n            instance_id,\n        }\n    }\n\n    // Private helper to get or build the inner reference\n    fn get_inner(&mut self) -> &Arc<Mutex<FunctionLogInner>> {\n        if self.inner.is_none() {\n            // We attempt to build or retrieve from the global tracer\n            let maybe_arc = {\n                let tracer = BAML_TRACER.lock().unwrap();\n                build_function_log(&tracer, &self.id)\n                    .expect(\"Function log expected to be present (no FunctionStart event?). Did you forget to track_function()?\")\n            };\n            self.inner = Some(maybe_arc);\n        }\n        self.inner.as_ref().unwrap()\n    }\n\n    pub fn id(&self) -> FunctionCallId {\n        self.id.clone()\n    }\n\n    // The methods below clone from the underlying data (no references).\n    pub fn function_name(&mut self) -> String {\n        self.get_inner().lock().unwrap().function_name.clone()\n    }\n\n    pub fn log_type(&mut self) -> String {\n        self.get_inner().lock().unwrap().r#type.clone()\n    }","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/tracingv2/storage/storage.rs#L527-L563","documentation":"BAML's tracing v2 storage looked up the function log entry for a traced function but found no FunctionStart event recorded for its id, so `build_function_log` failed inside `get_inner`. This is an internal invariant violation: any accessor (function_name, log_type, timing, usage, calls, raw_llm_response) on a FunctionLog requires the function to have been registered via track_function() before the event is read.","triggerScenarios":"Reading properties off a FunctionLog (e.g. .usage(), .timing(), .calls()) whose id was never registered with track_function() in the BAML_TRACER; a FunctionStart tracing event was missing or dropped before the accessor ran.","commonSituations":"Custom runtime/embedding integrations that construct log handles manually instead of calling track_function(); tracer state lost across thread/async boundaries; version mismatches where the tracing wire protocol changed and FunctionStart events are not emitted; reading a log object for a function whose call never actually started.","solutions":["Ensure track_function() is called for the function id before creating or reading any FunctionLog accessors.","Check that the tracing collector (BAML_TRACER) is initialized in the same process/runtime where events are emitted.","Update the BAML runtime and client bindings to matching versions so FunctionStart events are emitted in the expected format.","If you are integrating tracing manually, emit a FunctionStart event for the id before calling get_inner-derived accessors."],"exampleFix":"// before\nlet log = FunctionLog::new(id);\nlet usage = log.usage(); // panics: no FunctionStart event\n\n// after\ntracer.track_function(&id, \"MyFunction\"); // register first\nlet log = FunctionLog::new(id);\nlet usage = log.usage();","handlingStrategy":"validation","validationCode":"// Ensure the function id is tracked before reading log accessors\ntracer.track_function(&id, function_name);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call track_function() before constructing or reading FunctionLog objects","Keep BAML runtime and client bindings on matching versions","Do not build FunctionLog handles manually in integration code"],"tags":["rust","tracing","internal-invariant"],"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-14T05:17:10.506Z"}