{"record":{"id":"448eef05be31aa27","repo":"astral-sh/ruff","slug":"workspace-not-found-uri","errorCode":null,"errorMessage":"Workspace not found: {uri}","messagePattern":"Workspace not found: (.+?)","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ty_server/src/session.rs","lineNumber":998,"sourceCode":"    ///\n    /// # Errors\n    ///\n    /// This returns an error if the workspace folder has already been removed\n    /// or otherwise could not be found.\n    pub(crate) fn remove_workspace_folder(\n        &mut self,\n        client: &Client,\n        uri: &Uri,\n    ) -> anyhow::Result<()> {\n        tracing::info!(\"Removing workspace folder: {uri}\");\n\n        let path = uri\n            .to_file_path()\n            .map_err(|()| anyhow!(\"Workspace URI is not a file path: {uri}\"))?;\n        let workspace_path = SystemPathBuf::from_path_buf(path)\n            .map_err(|path| anyhow!(\"Workspace path is not valid UTF-8: {}\", path.display()))?;\n\n        anyhow::ensure!(\n            self.workspaces.unregister(&workspace_path),\n            \"Workspace not found: {uri}\",\n        );\n\n        // Note that it is somewhat unclear whether we actually need to\n        // clear diagnostics here. It seems that, at least in the case\n        // of VS Code, it will auto-clear any diagnostics not found in\n        // the workspace diagnostic response. Moreover, VS Code will\n        // re-request workspace diagnostics after removing a workspace\n        // folder.\n        //\n        // For now, we keep unconditionally clearing diagnostics on\n        // opened text documents for reasons of good sense, but it's\n        // possible that we don't even need to do that (when workspace\n        // diagnostics are enabled).\n        //\n        // See: https://github.com/astral-sh/ruff/pull/22953#discussion_r2745255350\n","sourceCodeStart":980,"sourceCodeEnd":1016,"githubUrl":"https://github.com/astral-sh/ruff/blob/5bb508f59481c1a02d5c7ff8568b9ffd8a763eef/crates/ty_server/src/session.rs#L980-L1016","documentation":"An anyhow error raised while removing a workspace folder: the URI was converted to a path successfully, but no registered workspace matches it — typically because it was already removed or never added. Distinct from the URI/UTF-8 conversion errors raised just before it.","triggerScenarios":"Thrown at crates/ty_server/src/session.rs:990 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the folder only once and after it was added","Check the registered workspace list before issuing didChangeWorkspaceFolders removals"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5bb508f59481c1a02d5c7ff8568b9ffd8a763eef","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}