{"record":{"id":"a4ecb6ed61b9cf35","repo":"BoundaryML/baml","slug":"no-source-root-contains","errorCode":null,"errorMessage":"No source root contains {}","messagePattern":"No source root contains (.+?)","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":38,"sourceCode":"    RequestSerializeError(serde_json::Error),\n    /// The client's sink is gone; nothing more can be delivered.\n    #[error(\"Client closed\")]\n    ClientClosed,\n    /// Bounded transport backpressure (LSP `RequestFailed`, `-32803`).\n    #[error(\"LSP outbound sink is saturated\")]\n    OutboundSaturated,\n    /// A frame larger than the transport limit (LSP `RequestFailed`,\n    /// `-32803`).\n    #[error(\"LSP outbound frame exceeds the transport limit\")]\n    OutboundOversized,\n    #[error(\"Invalid command arguments for command: {command}: {message}\")]\n    InvalidCommandArguments { command: String, message: String },\n    #[error(\"File not found: {}\", .0.display())]\n    FileNotFound(PathBuf),\n    #[error(\"Path is invalid: {}: {message}\", path.display())]\n    InvalidPath { path: PathBuf, message: String },\n    /// The document's path is under no known source root.\n    #[error(\"No source root contains {}\", .0.display())]\n    NoRootForPath(PathBuf),\n    /// Cancellation claimed the response while the request was queued or\n    /// running (LSP `RequestCanceled`, `-32800`).\n    #[error(\"Request canceled: {0}\")]\n    RequestCanceled(String),\n    /// The request's snapshot became stale under an applied source change\n    /// (LSP `ContentModified`, `-32801`).\n    #[error(\"Content modified: {0}\")]\n    ContentModified(String),\n    /// A valid request that cannot be served right now (LSP `RequestFailed`,\n    /// `-32803`).\n    #[error(\"{0}\")]\n    RequestFailed(String),\n    /// Violated invariants, panics, serialization (LSP `InternalError`,\n    /// `-32603`).\n    #[error(\"Internal error: {0}\")]\n    Internal(String),\n    /// Malformed params, position, or range (LSP `InvalidParams`, `-32602`).","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L20-L56","documentation":"LspError::NoRootForPath is returned when a document's path is not under any of the server's known source roots, so the server cannot attribute the file to a workspace/project context. Without a containing root the server cannot resolve project-relative configuration, imports, or generators, so it refuses the request with this error instead of guessing.","triggerScenarios":"Opening or requesting analysis for a file located outside all registered workspace folders / source roots; a single-file (detached) editor session with no workspace folder; the source-root configuration excludes the directory containing the file.","commonSituations":"Editing a .baml file in a scratch directory outside the project; opening a file via symlink whose real path lies outside the workspace; a misconfigured baml source root that points at a subdirectory while files live elsewhere.","solutions":["Open the project's root folder in the editor (not a loose file) so the server registers a workspace folder containing the document.","Add the file's directory to the workspace folders / multi-root workspace configuration.","Fix the source-root configuration in the server/client settings so it includes the document's path.","Move the file inside an existing recognized source root."],"exampleFix":"// before (client init)\nworkspaceFolders: []\n// after\nworkspaceFolders: [\n  { uri: 'file:///home/dev/my-project', name: 'my-project' }\n]","handlingStrategy":"validation","validationCode":"function isUnderRoot(uri, roots) {\n  const p = new URL(uri).pathname;\n  return roots.some(r => p.startsWith(new URL(r).pathname));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await request('textDocument/hover', params);\n} catch (e) {\n  if (e.message?.startsWith('No source root contains')) {\n    console.warn('Open the containing workspace folder to analyze', params.textDocument.uri);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Always open a project folder, not loose files, when using the BAML LSP","Keep workspaceFolders populated and accurate in the initialize params","Verify source-root settings cover every directory containing .baml files"],"tags":["lsp","workspace","path","configuration"],"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"}