{"record":{"id":"774814f84a102551","repo":"sinelaw/fresh","slug":"notfound","errorCode":"NotFound","errorMessage":"Path does not exist: {:?}","messagePattern":"Path does not exist: (.+?)","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/view/file_tree/tree.rs","lineNumber":39,"sourceCode":"    path_to_node: HashMap<PathBuf, NodeId>,\n    /// Root node ID\n    root_id: NodeId,\n    /// Next node ID to assign\n    next_id: usize,\n    /// Filesystem manager for async operations\n    fs_manager: Arc<FsManager>,\n}\n\nimpl FileTree {\n    /// Create a new file tree rooted at the given path\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the root path doesn't exist or isn't a directory.\n    pub async fn new(root_path: PathBuf, fs_manager: Arc<FsManager>) -> io::Result<Self> {\n        // Verify root path exists and is a directory\n        if !fs_manager.exists(&root_path).await {\n            return Err(io::Error::new(\n                io::ErrorKind::NotFound,\n                format!(\"Path does not exist: {:?}\", root_path),\n            ));\n        }\n\n        if !fs_manager.is_dir(&root_path).await? {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                format!(\"Path is not a directory: {:?}\", root_path),\n            ));\n        }\n\n        // Get root entry\n        let root_entry = fs_manager.get_entry(&root_path).await?;\n\n        // Create root node\n        let root_id = NodeId(0);\n        let root_node = TreeNode::new(root_id, root_entry.clone(), None);","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/view/file_tree/tree.rs#L21-L57","documentation":"`FileTree::new` validates its root before building the tree; if the filesystem manager reports the given path does not exist, it returns `io::ErrorKind::NotFound` with the path in the message. The tree cannot be rooted at a non-existent location.","triggerScenarios":"Constructing a `FileTree` with a `root_path` that fails `fs_manager.exists()` — deleted/renamed directory, typo in the path, relative path resolved against an unexpected cwd, or a virtual FS without that entry.","commonSituations":"Opening a project folder that was moved or deleted while the editor ran; passing a user-typed path with a typo; workspace config pointing at a stale directory.","solutions":["Check that the path exists (fs::metadata or fs_manager.exists) before constructing the tree","Correct the path/workspace configuration to an existing directory","Create the missing directory if it is expected to exist","Surface the error to the user with the path so they can pick a valid root"],"exampleFix":"// before\nlet tree = FileTree::new(cfg_root.clone(), fs.clone()).await?;\n// after\nif !fs.exists(&cfg_root).await {\n    eprintln!(\"root not found: {:?}\", cfg_root);\n    return Ok(None);\n}\nlet tree = FileTree::new(cfg_root.clone(), fs.clone()).await?;","handlingStrategy":"validation","validationCode":"if !std::path::Path::new(&root_path).is_dir() {\n    // route to error UI / pick another root\n}\n","typeGuard":null,"tryCatchPattern":"match FileTree::new(root_path, fs).await {\n    Err(e) if e.kind() == io::ErrorKind::NotFound => eprintln!(\"root missing: {}\", root_path.display()),\n    other => other?,\n}","preventionTips":["Validate workspace roots at startup with a clear user-facing error","Re-check existence before constructing trees after external changes","Store absolute canonical paths in config","Create missing default directories during setup"],"tags":["io","filesystem","not-found"],"backgroundTag":"directory-not-found","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}