{"record":{"id":"26a1f8b330cd1472","repo":"vectordotdev/vector","slug":"failed-to-create-output-dir-new-dir","errorCode":null,"errorMessage":"Failed to create output dir: {new_dir:?}","messagePattern":"Failed to create output dir: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/convert_config.rs","lineNumber":168,"sourceCode":") -> 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            }\n        }\n    } else {\n        let output_path = output_dir.join(\n            input_path\n                .with_extension(output_format.to_string().as_str())","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/convert_config.rs#L150-L186","documentation":"After computing the mirrored output subdirectory name, the walker creates it with fs::create_dir_all; failure panics with 'Failed to create output dir: <path>'. This mirrors the input directory structure into the output root.","triggerScenarios":"create_dir_all fails for the mirrored subdirectory: parent output dir is read-only, a same-named path component already exists as a regular file, path length limits are exceeded, or the disk is full.","commonSituations":"Reusing an output root that partially contains files where directories are expected, running as a user without write access to the output tree, or very deep input trees hitting PATH_MAX on Linux.","solutions":["Ensure the output root exists and is writable; remove conflicting regular files that block directory creation","Run with a user/group that has write permission on the output tree, or chown the output root","Shorten paths by using a shallower output root if PATH_MAX is the issue (use a path under a short tmpdir)","Patch to push the io::Error into the errors Vec rather than panicking"],"exampleFix":"// before\nfs::create_dir_all(&new_dir)\n    .unwrap_or_else(|_| panic!(\"Failed to create output dir: {new_dir:?}\"));\n// after\nif let Err(err) = fs::create_dir_all(&new_dir) {\n    errors.push(format!(\"Failed to create output dir {new_dir:?}: {err}\"));\n    continue;\n}","handlingStrategy":"validation","validationCode":"fn ensure_writable_dir(p: &std::path::Path) -> std::io::Result<()> {\n    std::fs::create_dir_all(p)?;\n    let probe = p.join(\".write_probe\");\n    std::fs::write(&probe, b\"\")?;\n    std::fs::remove_file(&probe)\n}","typeGuard":"fn is_writable_dir(p: &std::path::Path) -> bool { p.is_dir() && !fs::metadata(p).map(|m| m.permissions().readonly()).unwrap_or(true) }","tryCatchPattern":null,"preventionTips":["Pre-create and permission-check the output root before running","Use a short output root to stay under PATH_MAX for deep trees","Ensure no output component collides with an existing file"],"tags":["rust","panic","filesystem","mkdir"],"backgroundTag":"mkdir-permission-denied","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"}