astral-sh/ruff · error · anyhow::Error
Workspace URI is not valid UTF8
Error message
Workspace URI is not valid UTF8
What it means
An anyhow error raised while registering a workspace: the workspace URI's path component is not valid UTF-8. ty's path types require Unicode, so the URI cannot be converted to a workspace path and registration fails.
Solutions
- Use a workspace URI whose path is valid UTF-8
- Re-open the project from a Unicode-named directory
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ty_server/src/session.rs:1754 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/ruff@5bb508f594 (2026-09-05).
Data as JSON: /api/errors/fccf6f9c3dfc5e38.
Report an issue: GitHub.
Appendix: source
Thrown at crates/ty_server/src/session.rs:1671
///
/// This returns `true` when this workspace is added and `false`
/// when it has already been added.
///
/// It's the caller's responsibility to later call
/// [`Session::request_uninitialized_workspace_folder_configurations`] with
/// the resolved settings for this workspace. Registering and initializing
/// a workspace is a two-step process because the workspace are announced
/// to the server during the `initialize` request, but the resolved
/// settings are only available after the client has responded to the
/// `workspace/configuration` request.
fn register(&mut self, uri: Uri) -> anyhow::Result<bool> {
let path = uri
.to_file_path()
.map_err(|()| anyhow!("Workspace URI is not a file or directory: {uri:?}"))?;
// Realistically I don't think this can fail because we got the path from a Uri
let system_path = SystemPathBuf::from_path_buf(path)
.map_err(|_| anyhow!("Workspace URI is not valid UTF8"))?;
if self.workspaces.contains_key(&system_path) {
return Ok(false);
}
self.workspaces.insert(
system_path,
Workspace {
uri,
settings: Arc::new(WorkspaceSettings::default()),
initialized: false,
},
);
Ok(true)
}
/// Unregisters a workspace folder at the given path.
///View on GitHub (pinned to 5bb508f594)