{"record":{"id":"af4f12d1c6495907","repo":"sinelaw/fresh","slug":"filesystem-not-available","errorCode":null,"errorMessage":"Filesystem not available","messagePattern":"Filesystem not available","errorType":"exception","errorClass":"io::Error (Unsupported)","httpStatus":null,"severity":"error","filePath":"crates/fresh-editor-core/src/model/filesystem.rs","lineNumber":1641,"sourceCode":"        }\n        Ok(())\n    }\n}\n\n// ============================================================================\n// NoopFileSystem Implementation\n// ============================================================================\n\n/// No-op filesystem that returns errors for all operations\n///\n/// Used as a placeholder or in WASM builds where a VirtualFileSystem\n/// should be used instead.\n#[derive(Debug, Clone, Copy, Default)]\npub struct NoopFileSystem;\n\nimpl NoopFileSystem {\n    fn unsupported<T>() -> io::Result<T> {\n        Err(io::Error::new(\n            io::ErrorKind::Unsupported,\n            \"Filesystem not available\",\n        ))\n    }\n}\n\nimpl FileSystem for NoopFileSystem {\n    fn read_file(&self, _path: &Path) -> io::Result<Vec<u8>> {\n        Self::unsupported()\n    }\n\n    fn read_range(&self, _path: &Path, _offset: u64, _len: usize) -> io::Result<Vec<u8>> {\n        Self::unsupported()\n    }\n\n    fn write_file(&self, _path: &Path, _data: &[u8]) -> io::Result<()> {\n        Self::unsupported()\n    }","sourceCodeStart":1623,"sourceCodeEnd":1659,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor-core/src/model/filesystem.rs#L1623-L1659","documentation":"NoopFileSystem is a stub implementation of the filesystem trait used in tests/headless contexts. Every filesystem operation on it funnels through the private unsupported() helper, which returns io::ErrorKind::Unsupported with the message 'Filesystem not available'. It signals that no real filesystem is backed by this model instance.","triggerScenarios":"Any filesystem operation (read, write, metadata, listing) invoked on a model/session constructed with NoopFileSystem — typically headless tests, scripting sessions, or runs where the model was explicitly created without a real filesystem backend.","commonSituations":"Running editor logic in tests or CI with NoopFileSystem::default() as the backend; forgetting to swap in a real filesystem implementation before exercising file operations; using a script or harness that hardcodes the noop backend.","solutions":["Construct the model/session with a real filesystem implementation instead of NoopFileSystem","If this is a test, either assert on the Unsupported error or switch to a tempdir-backed filesystem","Guard filesystem-touching code paths so they are skipped when the backend is NoopFileSystem"],"exampleFix":"// before\nlet model = Model::new(NoopFileSystem::default());\nmodel.read_file(\"/tmp/x.txt\")?; // Unsupported: Filesystem not available\n// after\nlet model = Model::new(RealFileSystem::new());\nmodel.read_file(\"/tmp/x.txt\")?;","handlingStrategy":"validation","validationCode":"fn has_real_fs(model: &Model) -> bool { !std::ptr::eq(model.fs_type_id(), &std::any::TypeId::of::<NoopFileSystem>()) } // or track a bool at construction","typeGuard":"fn is_noop_fs(fs: &dyn FileSystem) -> bool { fs.as_any().is::<NoopFileSystem>() }","tryCatchPattern":"match model.write_file(path, data) { Err(e) if e.kind() == io::ErrorKind::Unsupported => eprintln!(\"no filesystem backend\"), other => other?, }","preventionTips":["Never ship NoopFileSystem in production paths; reserve it for tests","Centralize model construction so the fs backend choice is explicit","Add a debug_assert that real file operations aren't routed to the noop backend"],"tags":["filesystem","unsupported-operation","rust","io"],"backgroundTag":"unsupported-platform","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}