{"record":{"id":"2e89bbed2236841b","repo":"vectordotdev/vector","slug":"failed-to-get-entry-for-dir-input-path","errorCode":null,"errorMessage":"Failed to get entry for dir: {input_path:?}","messagePattern":"Failed to get entry for dir: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/convert_config.rs","lineNumber":158,"sourceCode":"    {\n        println!(\"Wrote result to {output_path:?}.\");\n    }\n    Ok(())\n}\n\nfn walk_dir_and_convert(\n    input_path: &Path,\n    output_dir: &Path,\n    output_format: Format,\n) -> Result<(), Vec<String>> {\n    let mut errors = Vec::new();\n\n    if input_path.is_dir() {\n        for entry in fs::read_dir(input_path)\n            .unwrap_or_else(|_| panic!(\"Failed to read dir: {input_path:?}\"))\n        {\n            let entry_path = entry\n                .unwrap_or_else(|_| panic!(\"Failed to get entry for dir: {input_path:?}\"))\n                .path();\n            let new_output_dir = if entry_path.is_dir() {\n                let last_component = entry_path\n                    .file_name()\n                    .unwrap_or_else(|| panic!(\"Failed to get file_name for {entry_path:?}\"));\n                let new_dir = output_dir.join(last_component);\n\n                if !new_dir.exists() {\n                    fs::create_dir_all(&new_dir)\n                        .unwrap_or_else(|_| panic!(\"Failed to create output dir: {new_dir:?}\"));\n                }\n                new_dir\n            } else {\n                output_dir.to_path_buf()\n            };\n\n            if let Err(new_errors) = walk_dir_and_convert(\n                &input_path.join(&entry_path),","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/convert_config.rs#L140-L176","documentation":"While iterating a directory listing, each fs::read_dir entry Result is unwrapped; a failed entry (e.g. the Dirent could not be read) panics with 'Failed to get entry for dir: <path>'. This is distinct from a failure to open the directory itself.","triggerScenarios":"A directory entry becomes unreadable between read_dir and iteration — the file is deleted or renamed concurrently, or an I/O error occurs while reading the entry metadata from the filesystem.","commonSituations":"Concurrent modification of the directory while the converter walks it (build/clean jobs running in parallel), flaky network filesystems (NFS) returning stale entries, or exceeding fd/inotify-related limits on very large directories.","solutions":["Re-run the tool once the directory is no longer being modified concurrently","Exclude directories that race with cleanup (run the converter on a snapshot/copy)","Check filesystem health (dmesg / fsck) if errors repeat on local disks","Patch to push the entry error into the errors Vec and continue with remaining entries"],"exampleFix":"// before\n.unwrap_or_else(|_| panic!(\"Failed to get entry for dir: {input_path:?}\"))\n// after\nlet entry = match entry {\n    Ok(e) => e,\n    Err(err) => {\n        errors.push(format!(\"Bad entry in {input_path:?}: {err}\"));\n        continue;\n    }\n};","handlingStrategy":"retry","validationCode":null,"typeGuard":"fn safe_entries(p: &std::path::Path) -> Vec<std::fs::DirEntry> {\n    fs::read_dir(p).map(|rd| rd.flatten().collect()).unwrap_or_default()\n}","tryCatchPattern":"match result {\n    Ok(v) => v,\n    Err(e) if e.kind() == io::ErrorKind::NotFound => continue, // entry vanished mid-walk\n    Err(e) => return Err(e),\n}","preventionTips":["Don't mutate directories while the converter is walking them","Use flatten()/filter_map to skip vanished entries instead of unwrapping","Retry the walk after concurrent jobs finish"],"tags":["rust","panic","filesystem","concurrency"],"backgroundTag":"file-read-failed","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}