BoundaryML/baml · error

InternalError

InternalError

Error message

File {} was not present in the project

What it means

`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.

Source

Thrown at engine/language_server/src/server/api/requests/go_to_definition.rs:57

            .clone();
        let path = url
            .to_file_path()
            .internal_error_msg("Could not convert URL to path")?;
        let Ok(project) = session.get_or_create_project(&path) else {
            return Ok(None);
        };

        let document_key = DocumentKey::from_url(
            &project.lock().baml_project.root_dir_name,
            &params.text_document_position_params.text_document.uri,
        )
        .internal_error()?;
        let guard = project.lock();
        let doc = guard
            .baml_project
            .files
            .get(&document_key)
            .ok_or(anyhow::anyhow!(
                "File {} was not present in the project",
                document_key
            ))
            .internal_error()?;
        let word = get_word_at_position(
            &doc.contents,
            &params.text_document_position_params.position,
        );
        let cleaned_word = trim_line(&word);
        if cleaned_word.is_empty() {
            return Ok(None);
        }
        let rt = guard.runtime().internal_error()?;
        let maybe_symbol = rt.search_for_symbol(&cleaned_word);
        match maybe_symbol {
            None => Ok(None),
            Some(symbol_location) => {
                let range = Range {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Open the target file in the editor once so it registers with the project, then retry.
  2. Confirm the file lives inside the baml_src directory the server tracks.
  3. Wait for project initialization / re-save the file to trigger indexing.
  4. Restart the language server if the file map is stale after bulk file moves.
Defensive patterns

Strategy: validation

Validate before calling

// Before issuing a definition request, confirm the doc is tracked
if !project.lock().baml_project.files.contains_key(&document_key) {
    tracing::warn!("definition skipped: doc not indexed");
    return Ok(None);
}

Try / catch

let doc = match guard.baml_project.files.get(&document_key) {
    Some(d) => d,
    None => return Ok(None), // graceful: untracked file
};

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/206a44e504d62369. Report an issue: GitHub.