BoundaryML/baml · error

InternalError

InternalError

Error message

File {} was not present in the project

What it means

The hover request handler converts the request URL to a DocumentKey and then looks it up in `baml_project.files`. If the document is absent from the project's file map, hover cannot proceed and this InternalError is raised after logging a warning. Same family as 1557 but for the hover request.

Source

Thrown at engine/language_server/src/server/api/requests/hover.rs:44

        notifier: Notifier,
        _requester: &mut Requester,
        params: HoverParams,
    ) -> Result<Option<types::Hover>> {
        let url = &params.text_document_position_params.text_document.uri;
        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().root_path(), url).internal_error()?;

        let text_document_item = match project.lock().baml_project.files.get(&document_key) {
            None => {
                tracing::warn!("*** HOVER: Failed to find doc {:?}", url);
                Err(anyhow::anyhow!(
                    "File {} was not present in the project",
                    url
                ))
            }
            Some(text_document) => Ok(TextDocumentItem {
                uri: url.clone(),
                language_id: "BAML".to_string(),
                text: text_document.contents.clone(),
                version: 1,
            }),
        }
        .internal_error()?;
        let position = params.text_document_position_params.position;
        // Just swallow the error here, we dont want hover failures to show error notifs for a user.
        let default_flags = vec!["beta".to_string()];
        let hover = match project.lock().handle_hover_request(
            &text_document_item,
            &position,

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Ensure the file is inside baml_src and recognized as a .baml source.
  2. Open/save the file so the server indexes it, then retry hover.
  3. Wait for the project's initial load to complete before hovering.
  4. Restart the language server if the in-memory file map is out of sync with disk.
Defensive patterns

Strategy: validation

Validate before calling

// Only hover in tracked .baml files inside baml_src
if !url.as_str().contains("/baml_src/") || !url.as_str().ends_with(".baml") {
    return;
}

Try / catch

let doc = match project.lock().baml_project.files.get(&document_key) {
    Some(d) => d,
    None => return Ok(None), // untracked file: skip hover quietly
};

Prevention

When it happens

Trigger: textDocument/hover on a file whose DocumentKey is not present in `baml_project.files` — file outside baml_src, never opened/indexed, or hover fired before project load completed.

Common situations: Hovering over identifiers in a non-BAML or untracked file; hovering immediately after opening a workspace before indexing finishes; baml_src misconfiguration excluding the file.

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/e3f95a03236e04f8. Report an issue: GitHub.