{"record":{"id":"09d5f24049402e09","repo":"astral-sh/ruff","slug":"virtual-path-does-not-exist-path","errorCode":null,"errorMessage":"Virtual path does not exist: {path}","messagePattern":"Virtual path does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_server/src/system.rs","lineNumber":345,"sourceCode":"            std::io::ErrorKind::PermissionDenied,\n            \"external commands are disabled in an untrusted workspace\",\n        ))\n    }\n\n    fn dyn_clone(&self) -> Box<dyn CommandExecutor> {\n        Box::new(Self)\n    }\n}\n\nfn not_a_text_document(path: impl Display) -> std::io::Error {\n    std::io::Error::new(\n        std::io::ErrorKind::InvalidInput,\n        format!(\"Input is not a text document: {path}\"),\n    )\n}\n\nfn virtual_path_not_found(path: impl Display) -> std::io::Error {\n    std::io::Error::new(\n        std::io::ErrorKind::NotFound,\n        format!(\"Virtual path does not exist: {path}\"),\n    )\n}\n\n/// Helper function to get the [`FileRevision`] of the given document.\nfn document_revision(document: &Document, index: &Index) -> FileRevision {\n    // The file revision is just an opaque number which doesn't have any significant meaning other\n    // than that the file has changed if the revisions are different.\n    #[expect(clippy::cast_sign_loss)]\n    match document {\n        Document::Text(text) => FileRevision::new(text.version() as u128),\n        Document::Notebook(notebook) => {\n            // VS Code doesn't always bump the notebook version when the cell content changes.\n            // Specifically, I noticed that VS Code re-uses the same version when:\n            // 1. Adding a new cell\n            // 2. Pasting some code that has an error\n            //","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ty_server/src/system.rs#L327-L363","documentation":"Sentinel io::Error (ErrorKind::NotFound) produced by the ty_server helper virtual_path_not_found when a file operation targets a path in ty's virtual (in-memory, LSP-managed) filesystem that has no corresponding entry. read_virtual_path_to_string and read_virtual_path_to_notebook call it instead of touching the OS filesystem so that requests for unsaved/virtual documents fail as a clean NotFound rather than an ENOENT from disk. Callers match on the kind to map it into an LSP 'file not found' response; callers should check virtual existence before invoking these readers.","triggerScenarios":"Thrown at crates/ty_server/src/system.rs:345 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the virtual path exists before reading","Handle NotFound at the call site and skip the missing virtual file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}