{"record":{"id":"206a44e504d62369","repo":"BoundaryML/baml","slug":"internalerror-file-was-not-present-in-the-project","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/go_to_definition.rs","lineNumber":57,"sourceCode":"            .clone();\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 document_key = DocumentKey::from_url(\n            &project.lock().baml_project.root_dir_name,\n            &params.text_document_position_params.text_document.uri,\n        )\n        .internal_error()?;\n        let guard = project.lock();\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 word = get_word_at_position(\n            &doc.contents,\n            &params.text_document_position_params.position,\n        );\n        let cleaned_word = trim_line(&word);\n        if cleaned_word.is_empty() {\n            return Ok(None);\n        }\n        let rt = guard.runtime().internal_error()?;\n        let maybe_symbol = rt.search_for_symbol(&cleaned_word);\n        match maybe_symbol {\n            None => Ok(None),\n            Some(symbol_location) => {\n                let range = Range {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_server/src/server/api/requests/go_to_definition.rs#L39-L75","documentation":"`go_to_definition` resolves the requested document key, then looks it up in `baml_project.files`. If the document is not tracked by the project's file map, this InternalError is raised — the server was asked for definition navigation in a file it does not currently hold in memory.","triggerScenarios":"textDocument/definition request for a DocumentKey that exists after URL->path conversion but is absent from `baml_project.files` — file never opened/indexed, opened before project load finished, or excluded from baml_src.","commonSituations":"Go-to-definition invoked in a non-.baml file or a .baml file outside baml_src; race where the file wasn't did_open'ed yet; project still initializing after startup.","solutions":["Open the target file in the editor once so it registers with the project, then retry.","Confirm the file lives inside the baml_src directory the server tracks.","Wait for project initialization / re-save the file to trigger indexing.","Restart the language server if the file map is stale after bulk file moves."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before issuing a definition request, confirm the doc is tracked\nif !project.lock().baml_project.files.contains_key(&document_key) {\n    tracing::warn!(\"definition skipped: doc not indexed\");\n    return Ok(None);\n}","typeGuard":null,"tryCatchPattern":"let doc = match guard.baml_project.files.get(&document_key) {\n    Some(d) => d,\n    None => return Ok(None), // graceful: untracked file\n};","preventionTips":["Only request definition inside tracked baml_src files.","did_open files before navigating from them.","Let project initialization finish after startup."],"tags":["lsp","go-to-definition","file-not-found","baml"],"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"}