{"record":{"id":"3b3b945af7ebe888","repo":"BoundaryML/baml","slug":"internalerror","errorCode":"InternalError","errorMessage":"Could not convert url to path {}: {e:?}","messagePattern":"Could not convert url to path (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_server/src/edit.rs","lineNumber":78,"sourceCode":"        // Ensure our relative path doesn't begin with a path separator.\n        let relative_path = relative_path\n            .strip_prefix(std::path::MAIN_SEPARATOR_STR)\n            .unwrap_or(relative_path);\n\n        let absolute_path = root_path.join(relative_path);\n        // let aboslute_url = Url::from_file_path(absolute_path)\n        //     .map_err(|_| anyhow::anyhow!(\"Could not convert path to URL\"))?;\n        Ok(DocumentKey(absolute_path))\n    }\n\n    /// A flexible constructor that can take any URL delivered by the LSP.\n    /// It uses the same logic as `DocumentKey::from_path`.\n    pub fn from_url(root_path: &Path, url: &Url) -> anyhow::Result<Self> {\n        Self::from_path(\n            root_path,\n            &PathBuf::from(\n                &url.to_file_path()\n                    .map_err(|e| anyhow::anyhow!(\"Could not convert url to path {}: {e:?}\", url))?,\n            ),\n        )\n    }\n\n    pub fn unchecked_to_string(&self) -> String {\n        self.0\n            .as_os_str()\n            .to_str()\n            .expect(\"TODO: Assumed valid string\")\n            .to_string()\n    }\n}\n\nimpl std::fmt::Display for DocumentKey {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        // TODO: Fix.\n        let str = format!(\"{:?}\", self.0);\n        str.fmt(f)","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_server/src/edit.rs#L60-L96","documentation":"`DocumentKey::from_url` converts an LSP document URL into a filesystem path via `Url::to_file_path()`; if the URL is not a valid `file://` URL convertible to a path, this InternalError is raised with the offending URL. The LSP client sent a URI the server cannot map onto the workspace filesystem.","triggerScenarios":"A request (did_open, did_change, hover, etc.) supplies a `Url` that `to_file_path()` rejects — non-file schemes (untitled:, http:, virtual docs), percent-encoding edge cases, or a URL not representing a local path.","commonSituations":"Editor extensions opening virtual/untitled documents; remote or containerized editors producing non-file URIs; clients sending improperly encoded URIs on Windows.","solutions":["Check the URI in the error and confirm it uses the file:// scheme and points inside the workspace.","Exclude virtual/untitled documents from being treated as BAML files (open them as plain text).","Upgrade the LSP client/extension if it sends malformed URIs.","If working remotely, ensure the language server runs in the same filesystem context as the URIs."],"exampleFix":"// problematic URI sent by client\nuntitled:Untitled-1\n// expected\nfile:///home/user/project/baml_src/main.baml","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_local_file_url(url: &Url) -> bool {\n    url.scheme() == \"file\" && url.to_file_path().is_ok()\n}","tryCatchPattern":"if !is_local_file_url(url) {\n    tracing::warn!(\"skipping non-file document: {url}\");\n    return Ok(None);\n}","preventionTips":["Only send file:// URIs to the BAML language server.","Exclude untitled/virtual documents from BAML processing.","Run the server in the same filesystem context that owns the URIs."],"tags":["lsp","uri","internal-error","baml"],"backgroundTag":"invalid-url-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"}