{"record":{"id":"b539ce50066f82a8","repo":"BoundaryML/baml","slug":"could-not-update-runtime-e","errorCode":null,"errorMessage":"Could not update runtime: {e}","messagePattern":"Could not update runtime: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"engine/language_server/src/session.rs","lineNumber":424,"sourceCode":"                if project.lock().baml_project.files.contains_key(doc_key) {\n                    project\n                        .lock()\n                        .baml_project\n                        .unsaved_files\n                        .insert(doc_key.clone(), text_document);\n                    let _elapsed = start_time.elapsed();\n\n                    {\n                        let default_flags = vec![\"beta\".to_string()];\n                        project.lock().update_runtime(\n                            notifier.clone(),\n                            self.baml_settings\n                                .feature_flags\n                                .as_ref()\n                                .unwrap_or(&default_flags),\n                        )\n                    }\n                    .map_err(|e| anyhow::anyhow!(\"Could not update runtime: {e}\"))?;\n                    let _elapsed = start_time.elapsed();\n                }\n                Ok::<(), anyhow::Error>(())\n            })?;\n        Ok(())\n    }\n\n    /// De-registers a document, specified by its key.\n    /// Calling this multiple times for the same document is a logic error.\n    pub(crate) fn close_document(&self, key: &DocumentKey) -> anyhow::Result<()> {\n        let mut index = self.index.lock();\n        index.close_document(key)?;\n        Ok(())\n    }\n\n    /// Returns a reference to the index.\n    pub fn index(&self) -> &Arc<Mutex<index::Index>> {\n        &self.index","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_server/src/session.rs#L406-L442","documentation":"In Session::update_text_document, after applying document changes the server rebuilds the BAML runtime; any failure during that rebuild is wrapped as 'Could not update runtime'. The document still updates, but diagnostics/runtime state cannot be refreshed.","triggerScenarios":"didChange introduces BAML sources that fail to compile into a runtime (syntax errors, unknown functions/clients, invalid config), so runtime construction returns Err.","commonSituations":"Mid-edit transient states (half-typed function while typing); referencing a client/model not defined yet; deleting a definition still referenced elsewhere; invalid generator or provider configuration in baml files.","solutions":["Read the inner error to locate the failing BAML construct","Complete or fix the in-progress edit so sources compile","Ensure referenced functions/clients/generators exist and are valid","Ignore transient occurrences while typing if the server recovers on the next change; otherwise restart the server"],"exampleFix":"// before: mid-edit referencing missing client\nclient MyClient undefined\n// after: define the client first\nclient MyClient { provider openai options { model gpt-4o } }","handlingStrategy":"try-catch","validationCode":"// lint baml text client-side before didChange\nconst diags = await bamlLinter.check(newText); // only notify if no fatal errors","typeGuard":null,"tryCatchPattern":"try { await sendDidChange(uri, changes); } catch (e) { if (String(e).includes('Could not update runtime')) { /* expected during editing; rely on next change */ } else throw e; }","preventionTips":["Expect transient failures mid-edit; verify sources are valid when typing pauses","Define clients/providers before referencing them","Keep baml config consistent with feature flags","Watch the diagnostics panel for the underlying parse error"],"tags":["lsp","runtime","rust","diagnostics"],"backgroundTag":"schema-validation-failed","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"}