{"record":{"id":"4ea1b78df2ff1fac","repo":"BoundaryML/baml","slug":"internalerror-4ea1b7","errorCode":"InternalError","errorMessage":"File {} was not present in the project","messagePattern":"File (.+?) was not present in the project","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_server/src/server/api/requests/rename.rs","lineNumber":52,"sourceCode":"        let url = params.text_document_position.text_document.uri;\n        let path = url\n            .to_file_path()\n            .internal_error_msg(\"Could not convert URL to path\")?;\n        let Ok(project) = session.get_or_create_project(&path) else {\n            return Ok(None);\n        };\n\n        let res = {\n            let mut guard = project.lock();\n            let document_key =\n                DocumentKey::from_url(&PathBuf::from(guard.root_path()), &url).internal_error()?;\n\n            // Get the symbol under point.\n            let doc = guard\n                .baml_project\n                .files\n                .get(&document_key)\n                .ok_or(anyhow::anyhow!(\n                    \"File {} was not present in the project\",\n                    document_key\n                ))\n                .internal_error()?;\n            let symbol =\n                get_word_at_position(&doc.contents, &params.text_document_position.position);\n            let new_symbol = params.new_name;\n\n            // If the symbol is a class, find all occurrences and replace them.\n            let default_flags = vec![\"beta\".to_string()];\n            let runtime = guard.baml_project.runtime(\n                HashMap::new(),\n                session\n                    .baml_settings\n                    .feature_flags\n                    .as_ref()\n                    .unwrap_or(&default_flags),\n            );","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_server/src/server/api/requests/rename.rs#L34-L70","documentation":"This InternalError is raised by the BAML language server's rename request handler when the document key sent by the client is not found in the project's file map. The server cannot compute a rename because it has no tracked file matching the client's document, usually meaning the server and client state are out of sync.","triggerScenarios":"Calling the LSP textDocument/rename request with a document URI that was never opened via didOpen, was closed via didClose, or whose key does not match any file registered in baml_project.files.","commonSituations":"Clients racing a rename with file close, stale editor buffers pointing at deleted/moved .baml files, tests invoking the rename handler with a fabricated document key, or the project file watcher not having indexed the file yet.","solutions":["Ensure the file is opened/indexed in the project (didOpen or project load) before issuing a rename request.","Verify the document URI passed to rename exactly matches the key format the server stores in baml_project.files.","Check that the project loader/file watcher picked up the file (reload the window or restart the language server).","Return a proper RequestFailed/invalid-params error to the client instead of InternalError when the document is absent."],"exampleFix":"// before\nlet doc = guard.baml_project.files.get(&document_key).ok_or(anyhow::anyhow!(\"File {} was not present in the project\", document_key)).internal_error()?;\n// after\nlet Some(doc) = guard.baml_project.files.get(&document_key) else {\n    return Err(jsonrpc::Error::invalid_params(format!(\"File {} is not open in the project\", document_key)));\n};","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["lsp","rename","internal-error"],"backgroundTag":"resource-not-found","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"}