vectordotdev/vector · error
Failed to get file_name for
Error message
Failed to get file_name for {entry_path:?} What it means
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.
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
Example fix
// before
.unwrap_or_else(|| panic!("Failed to get file_name for {entry_path:?}"));
// after
let last_component = match entry_path.file_name() {
Some(name) => name,
None => continue, // skip degenerate paths like '..' or root
}; Defensive patterns
Strategy: validation
Validate before calling
fn has_file_name(p: &std::path::Path) -> bool { p.file_name().is_some() } Type guard
fn base_name(p: &std::path::Path) -> Option<String> { p.file_name().map(|s| s.to_string_lossy().into_owned()) } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Symlink loops or entries pointing at parent directories in unusual directory layouts; input trees generated by scripts that create '..' entries or paths terminated with '/../'.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- Failed to get extension for
- Failed to bind to listener socket at path
- Failed to create output dir
- Failed to create output dir(s)
- Failed to get entry for dir
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/5c958a4a1f084851.
Report an issue: GitHub.
Appendix: source
Thrown at src/convert_config.rs:163
fn walk_dir_and_convert(
input_path: &Path,
output_dir: &Path,
output_format: Format,
) -> Result<(), Vec<String>> {
let mut errors = Vec::new();
if input_path.is_dir() {
for entry in fs::read_dir(input_path)
.unwrap_or_else(|_| panic!("Failed to read dir: {input_path:?}"))
{
let entry_path = entry
.unwrap_or_else(|_| panic!("Failed to get entry for dir: {input_path:?}"))
.path();
let new_output_dir = if entry_path.is_dir() {
let last_component = entry_path
.file_name()
.unwrap_or_else(|| panic!("Failed to get file_name for {entry_path:?}"));
let new_dir = output_dir.join(last_component);
if !new_dir.exists() {
fs::create_dir_all(&new_dir)
.unwrap_or_else(|_| panic!("Failed to create output dir: {new_dir:?}"));
}
new_dir
} else {
output_dir.to_path_buf()
};
if let Err(new_errors) = walk_dir_and_convert(
&input_path.join(&entry_path),
&new_output_dir,
output_format,
) {
errors.extend(new_errors);
}View on GitHub (pinned to bdb87aeaa4)