{"record":{"id":"08fbbb98ca08cafe","repo":"zed-industries/zed","slug":"failed-to-read-directory-entry-in-path","errorCode":null,"errorMessage":"failed to read directory entry in {path:?}","messagePattern":"failed to read directory entry in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fs/src/fs.rs","lineNumber":710,"sourceCode":"fn read_dir_entries(path: PathBuf) -> Result<impl Send + Iterator<Item = Result<PathBuf>>> {\n    use rustix::fs::{Dir, Mode, OFlags};\n    use std::ffi::OsStr;\n    use std::os::unix::ffi::OsStrExt;\n\n    let directory_fd = rustix::fs::open(\n        &path,\n        OFlags::RDONLY | OFlags::DIRECTORY | OFlags::CLOEXEC,\n        Mode::empty(),\n    )\n    .with_context(|| format!(\"failed to open directory {path:?}\"))?;\n    let directory =\n        Dir::new(directory_fd).with_context(|| format!(\"failed to read directory {path:?}\"))?;\n\n    Ok(directory.filter_map(move |entry| {\n        let entry = match entry {\n            Ok(entry) => entry,\n            Err(error) => {\n                return Some(Err(anyhow::Error::new(error)\n                    .context(format!(\"failed to read directory entry in {path:?}\"))));\n            }\n        };\n        let name = entry.file_name().to_bytes();\n        if name == b\".\" || name == b\"..\" {\n            return None;\n        }\n        Some(Ok(path.join(OsStr::from_bytes(name))))\n    }))\n}\n\n#[cfg(not(unix))]\nfn read_dir_entries(path: PathBuf) -> Result<impl Send + Iterator<Item = Result<PathBuf>>> {\n    let entries =\n        std::fs::read_dir(&path).with_context(|| format!(\"failed to open directory {path:?}\"))?;\n    Ok(entries.map(move |entry| {\n        entry\n            .map(|entry| entry.path())","sourceCodeStart":692,"sourceCodeEnd":728,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/fs/src/fs.rs#L692-L728","documentation":"Raised in read_dir_entries when iterating the opened directory (Dir::new/handle on the already-open fd) fails while yielding entries, e.g. the directory was removed or an I/O error occurred mid-listing. The directory path is included for diagnosis.","triggerScenarios":"Thrown at crates/fs/src/fs.rs:665 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Propagate the per-entry error to the consumer rather than silently skipping it","Retry the directory scan; transient errors can occur when entries change during iteration","Check filesystem health if the same directory consistently fails"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}