{"record":{"id":"5c958a4a1f084851","repo":"vectordotdev/vector","slug":"failed-to-get-file-name-for-entry-path","errorCode":null,"errorMessage":"Failed to get file_name for {entry_path:?}","messagePattern":"Failed to get file_name for (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/convert_config.rs","lineNumber":163,"sourceCode":"\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),\n                &new_output_dir,\n                output_format,\n            ) {\n                errors.extend(new_errors);\n            }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/convert_config.rs#L145-L181","documentation":"For each subdirectory entry, walk_dir_and_convert derives the mirrored output directory name via Path::file_name(). file_name() returns None only for paths ending in '..' or the root, so this panic indicates the entry path resolved to such a degenerate form.","triggerScenarios":"An entry path whose last component is '..' — e.g. a directory containing a '..' symlinked entry or the walker itself being invoked on path components that normalize to the root, making file_name() return None.","commonSituations":"Symlink loops or entries pointing at parent directories in unusual directory layouts; input trees generated by scripts that create '..' entries or paths terminated with '/../'.","solutions":["Inspect the directory tree for entries named or linking to '..' (`find . -name '..' -o -type l`)","Canonicalize paths before walking (std::fs::canonicalize) so file_name() is well-defined","Patch the walker to skip entries whose file_name() is None instead of panicking"],"exampleFix":"// before\n.unwrap_or_else(|| panic!(\"Failed to get file_name for {entry_path:?}\"));\n// after\nlet last_component = match entry_path.file_name() {\n    Some(name) => name,\n    None => continue, // skip degenerate paths like '..' or root\n};","handlingStrategy":"validation","validationCode":"fn has_file_name(p: &std::path::Path) -> bool { p.file_name().is_some() }","typeGuard":"fn base_name(p: &std::path::Path) -> Option<String> { p.file_name().map(|s| s.to_string_lossy().into_owned()) }","tryCatchPattern":null,"preventionTips":["Canonicalize input roots with fs::canonicalize before walking","Reject or skip paths ending in '..' or '/'; validate tree layout before conversion","Avoid generating directories/symlinks named '..' in source trees"],"tags":["rust","panic","filesystem","path"],"backgroundTag":"path-traversal-blocked","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"}