{"record":{"id":"e176123b58bc2098","repo":"BoundaryML/baml","slug":"path-is-invalid-message","errorCode":null,"errorMessage":"Path is invalid: {}: {message}","messagePattern":"Path is invalid: (.+?): (.+?)","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":35,"sourceCode":"    #[error(\"Request not supported: {0}\")]\n    RequestNotSupported(String),\n    #[error(\"Failed to serialize request result: {0}\")]\n    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`).","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L17-L53","documentation":"LspError::InvalidPath is raised when a supplied path exists as a string but cannot be converted into a valid filesystem path (e.g. contains illegal characters, fails to parse as a URI, or is otherwise malformed). The error includes both the offending path and a message explaining why it was rejected. It protects the server from operating on nonsense paths.","triggerScenarios":"A document URI fails to parse into a PathBuf (invalid scheme, percent-encoding problems, non-UTF8 bytes); a path with illegal characters on the host OS is passed in a request; custom tooling sends relative or synthetic paths where an absolute file URI is required.","commonSituations":"Windows-style paths or backslashes sent from a client to a Unix-hosted server; unencoded spaces or '#'/'?' in URIs; virtual or in-memory document schemes (untitled:, memory:) passed where a real file path is required.","solutions":["Print the path from the error and validate it parses as a proper file:// URI before sending requests.","Percent-encode special characters (spaces, #, ?) in document URIs on the client side.","Convert relative paths to absolute paths anchored at the workspace root before sending.","Avoid sending virtual/unsupported URI schemes to requests that require real filesystem paths."],"exampleFix":"// before\nconst uri = 'file:///my project/prompts#v2.baml';\n// after\nconst uri = 'file:///my%20project/prompts%23v2.baml';","handlingStrategy":"validation","validationCode":"function isValidFileUri(uri) {\n  try {\n    const u = new URL(uri);\n    return u.protocol === 'file:' && !/\\\\/.test(u.pathname);\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await request('textDocument/documentSymbol', { textDocument: { uri } });\n} catch (e) {\n  if (e.message?.startsWith('Path is invalid')) {\n    console.warn('Unparseable path, skipping:', uri);\n    return;\n  }\n  throw e;\n}","preventionTips":["Always build URIs with a URL/URI encoder, never by string concatenation","Percent-encode spaces and reserved characters in paths","Reject backslash/Windows-style paths before sending on non-Windows servers"],"tags":["lsp","path","uri","validation"],"backgroundTag":"invalid-argument-format","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"}