BoundaryML/baml · error · LspError
File not found: {}
Error message
File not found: {} What it means
LspError::FileNotFound is returned when the server is asked to operate on a file whose path does not exist on disk. The display form is 'File not found: <path>' using the PathBuf's display representation. It is thrown instead of panicking so the LSP client receives a clean error response for requests that reference a missing document.
Source
Thrown at baml_language/crates/baml_lsp/src/error.rs:33
#[error("{0}")]
RequestExtractError(lsp_server::ExtractError<lsp_server::Request>),
#[error("Request not supported: {0}")]
RequestNotSupported(String),
#[error("Failed to serialize request result: {0}")]
RequestSerializeError(serde_json::Error),
/// The client's sink is gone; nothing more can be delivered.
#[error("Client closed")]
ClientClosed,
/// Bounded transport backpressure (LSP `RequestFailed`, `-32803`).
#[error("LSP outbound sink is saturated")]
OutboundSaturated,
/// A frame larger than the transport limit (LSP `RequestFailed`,
/// `-32803`).
#[error("LSP outbound frame exceeds the transport limit")]
OutboundOversized,
#[error("Invalid command arguments for command: {command}: {message}")]
InvalidCommandArguments { command: String, message: String },
#[error("File not found: {}", .0.display())]
FileNotFound(PathBuf),
#[error("Path is invalid: {}: {message}", path.display())]
InvalidPath { path: PathBuf, message: String },
/// The document's path is under no known source root.
#[error("No source root contains {}", .0.display())]
NoRootForPath(PathBuf),
/// Cancellation claimed the response while the request was queued or
/// running (LSP `RequestCanceled`, `-32800`).
#[error("Request canceled: {0}")]
RequestCanceled(String),
/// The request's snapshot became stale under an applied source change
/// (LSP `ContentModified`, `-32801`).
#[error("Content modified: {0}")]
ContentModified(String),
/// A valid request that cannot be served right now (LSP `RequestFailed`,
/// `-32803`).
#[error("{0}")]
RequestFailed(String),View on GitHub (pinned to bd85ce9dee)
Solutions
- Verify the file exists at the exact path in the error message on the machine running the language server.
- Re-open or re-save the document in the editor so the client sends a didOpen notification before other requests.
- Check that the client and server agree on the workspace root / mount points (containers, remote SSH, WSL).
- Refresh the client's file index if files were moved or deleted externally.
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
function fileExists(uri) {
const p = new URL(uri).pathname;
return fs.existsSync(p) && fs.statSync(p).isFile();
} Try / catch
try {
await request('textDocument/definition', params);
} catch (e) {
if (e.message?.startsWith('File not found')) {
console.warn('Document missing on server filesystem:', params.textDocument.uri);
return [];
}
throw e;
} Prevention
- Send didOpen for every document before issuing analysis requests
- Check filesystem existence when running client and server in different mounts/containers
- Purge stale URIs from client caches after file moves/deletes
When it happens
Trigger: A textDocument request (definition, hover, formatting, etc.) references a URI that was never opened and does not exist; the file was deleted between the client's index and the request; a path is resolved relative to the wrong working directory.
Common situations: Editor holds a stale buffer for a deleted/moved .baml file; client sends absolute URIs that don't resolve on the server's filesystem (e.g. remote-container path mismatch); typo'd or reconstructed file paths in generated tooling.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- toolchain binary not found: {}{origin}
- no filesystem is attached to this server ({})
- Path is invalid: {}: {message}
- No source root contains {}
- native path is not absolute: {0}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/8e121cb2ec4b8328.
Report an issue: GitHub.