biomejs/biome · error
To to have a UTF-8 path
Error message
To to have a UTF-8 path
What it means
Error "To to have a UTF-8 path" thrown in biomejs/biome.
Source
Thrown at crates/biome_lsp/src/session.rs:557
// also lets this task see the latest request before deciding whether to
// schedule another diagnostics update.
if entry.rerun_after_current.swap(false, Ordering::AcqRel) {
let latest_version = entry.scheduled_version.load(Ordering::Acquire);
if latest_version != version && !entry.closed.load(Ordering::Acquire) {
self.spawn_delayed_diagnostics(url, entry, latest_version);
}
}
}
pub(crate) fn file_path(&self, url: &Uri) -> Result<BiomePath> {
let path_to_file = match url.to_file_path() {
None => {
// If we can't create a path, it's probably because the file doesn't exist.
// It can be a newly created file that it's not on disk
Utf8PathBuf::from(url.path().to_string())
}
Some(path) => Utf8PathBuf::from_path_buf(path.as_ref().to_path_buf())
.expect("To to have a UTF-8 path"),
};
Ok(BiomePath::new(path_to_file))
}
/// Computes diagnostics for the file matching the provided url and publishes
/// them to the client. Called from [`handlers::text_document`] when a file's
/// contents changes.
#[tracing::instrument(level = "debug", skip_all, fields(url = display(url.as_str()), diagnostic_count), err)]
pub(crate) async fn update_diagnostics(&self, url: Uri) -> Result<(), LspError> {
let Some(doc) = self.document(&url) else {
return Ok(());
};
self.update_diagnostics_for_document(url.clone(), doc, None)
.await
}
async fn update_diagnostics_for_version(View on GitHub (pinned to 0fca643d22)
Solutions
- Ensure the URI received by the LSP server maps to a valid UTF-8 file path.
- Reject or normalize non-UTF-8 document URIs at the session boundary.
Example fix
let path = url_to_path(&uri).ok_or_else(|| /* invalid URI error */)?;
When it happens
Trigger: Thrown at crates/biome_lsp/src/session.rs:556 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of biomejs/biome@0fca643d22 (2026-08-20).
Data as JSON: /api/errors/0968ebf1c78bd706.
Report an issue: GitHub.