{"record":{"id":"9fddd8106b8abd61","repo":"astral-sh/ruff","slug":"reading-a-notebook-from-the-vendored-file-system-i","errorCode":null,"errorMessage":"Reading a notebook from the vendored file system is not supported.","messagePattern":"Reading a notebook from the vendored file system is not supported\\.","errorType":"error_code","errorClass":"NotebookError","httpStatus":null,"severity":"error","filePath":"crates/ruff_db/src/files.rs","lineNumber":439,"sourceCode":"            }\n        }\n    }\n\n    /// Reads the content of the file into a [`Notebook`].\n    ///\n    /// Reading the same file multiple times isn't guaranteed to return the same content. It's possible\n    /// that the file has been modified in between the reads.\n    pub(crate) fn read_to_notebook(&self, db: &dyn Db) -> Result<Notebook, NotebookError> {\n        let path = self.path(db);\n\n        match path {\n            FilePath::System(system) => {\n                // Add a dependency on the revision to ensure the operation gets re-executed when the file changes.\n                let _ = self.revision(db);\n\n                db.system().read_to_notebook(system)\n            }\n            FilePath::Vendored(_) => Err(NotebookError::Io(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                \"Reading a notebook from the vendored file system is not supported.\",\n            ))),\n            FilePath::SystemVirtual(system_virtual) => {\n                // Add a dependency on the revision to ensure the operation gets re-executed when the file changes.\n                let _ = self.revision(db);\n\n                db.system().read_virtual_path_to_notebook(system_virtual)\n            }\n        }\n    }\n\n    /// Refreshes the file metadata by querying the file system if needed.\n    ///\n    /// Directory listings are invalidated if the path's file status changed, its prior status is\n    /// unknown, or if `path` is itself a directory.\n    pub fn sync_path(db: &mut dyn Db, path: &SystemPath) {\n        let absolute = SystemPath::absolute(path, db.system().current_directory());","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_db/src/files.rs#L421-L457","documentation":"This NotebookError wraps an io::Error (kind InvalidInput) thrown when `read_to_notebook` is called on a file whose path lives on the vendored file system. Notebooks can only be read from the real system file system; vendored (in-memory, bundled) paths do not support notebook deserialization, so the query deliberately returns this error.","triggerScenarios":"Calling `source_text`/`read_to_notebook` on a `File` whose `FilePath` is `FilePath::Vendored(_)` — e.g. ty resolving a notebook path that resolves to a vendored typeshed/bundled resource.","commonSituations":"Analysis code that assumes every file with a `.ipynb`-style path is on disk, tests or tools pointing at vendored stubs, path-resolution bugs mapping a user notebook to the vendored FS.","solutions":["Check `file.path(db)` and skip vendored paths before requesting notebook contents","Fall back to plain `read_text`/stub handling for vendored files instead of notebook parsing","Fix path resolution so real notebooks map to `FilePath::System`"],"exampleFix":"// before\nlet notebook = file.read_to_notebook(db)?;\n// after\nif matches!(file.path(db), FilePath::Vendored(_)) {\n    return Ok(None); // vendored files are never notebooks\n}\nlet notebook = file.read_to_notebook(db)?;","handlingStrategy":"type-guard","validationCode":"path_kind = type(file.path(db))\nif path_kind is FilePath.Vendored:\n    skip_notebook_read(file)","typeGuard":"fn is_system_file(file: &File<'_>, db: &dyn Files) -> bool {\n    matches!(file.path(db), FilePath::System(_))\n}","tryCatchPattern":"match file.read_to_notebook(db) {\n    Err(e) if matches!(e.io_error_kind(), Some(std::io::ErrorKind::InvalidInput)) => Ok(None),\n    Err(e) => Err(e),\n    Ok(nb) => Ok(Some(nb)),\n}","preventionTips":["Check FilePath kind before any notebook-specific read","Treat vendored paths as stub-only resources","Fix path resolution so user notebooks always map to system paths"],"tags":["filesystem","notebooks","unsupported"],"backgroundTag":"unsupported-file-system-operation","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"}