{"record":{"id":"a1e42b98f4e36a3a","repo":"gitbutlerapp/gitbutler","slug":"src-is-not-a-directory","errorCode":null,"errorMessage":"'{src}' is not a directory","messagePattern":"'(.+?)' is not a directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-feedback/src/zip.rs","lineNumber":21,"sourceCode":"    io::{self, Read, Write},\n    path,\n    path::{Path, PathBuf},\n};\n\nuse anyhow::{Result, bail};\nuse walkdir::{DirEntry, WalkDir};\nuse zip::{CompressionMethod, ZipWriter, write::SimpleFileOptions};\n\n/// Create a zip file from the *contents* of `src_dir` and write the zip file out to `dst_file`,\n/// possibly overwriting it if it exists.\npub fn create_zip_file_from_dir(\n    src_dir: impl AsRef<Path>,\n    dst_file: impl AsRef<Path>,\n) -> anyhow::Result<PathBuf> {\n    let src_dir = src_dir.as_ref();\n    let dst_file = dst_file.as_ref();\n    if !src_dir.is_dir() {\n        bail!(\"'{src}' is not a directory\", src = src_dir.display());\n    }\n\n    let file = fs::File::create(dst_file)?;\n    zip_dir(\n        &mut WalkDir::new(src_dir).into_iter().filter_map(Result::ok),\n        src_dir,\n        file,\n    )?;\n\n    Ok(dst_file.to_owned())\n}\n\n/// Create a zip file with `src` content in a single-file archive, with the file named `src_file_name`,\n/// and write the zip file out to `dst_file`, possibly overwriting it if it exists.\npub fn create_zip_file_from_content(\n    src: &str,\n    src_file_name: &str,\n    dst_file: impl AsRef<Path>,","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-feedback/src/zip.rs#L3-L39","documentation":"`but-feedback` zips a directory (repository or logs) for bug reports. Before creating the archive it checks that the source path is actually a directory; if not (missing path, a file, or a dangling symlink), it bails with the path in the message.","triggerScenarios":"Calling create_zip_file_from_dir (directly or via zip_entire_repository / zip_logs) with a src_dir path that does not exist or points to a regular file instead of a directory.","commonSituations":"Logs directory not yet created on a fresh install; repository path moved or deleted before zip; passing a file path instead of a directory; wrong workspace root configured.","solutions":["Check the path exists and is a directory before calling: std::path::Path::new(src).is_dir()","Create the directory if it legitimately should exist (e.g. create the logs dir before zipping)","Correct the configured repository/logs path in the caller"],"exampleFix":"// before\ncreate_zip_file_from_dir(\"/maybe/missing/logs\", out).await?;\n// after\nif !Path::new(\"/maybe/missing/logs\").is_dir() {\n    std::fs::create_dir_all(\"/maybe/missing/logs\")?;\n}\ncreate_zip_file_from_dir(\"/maybe/missing/logs\", out).await?;","handlingStrategy":"validation","validationCode":"let src = Path::new(src_dir);\nif !src.is_dir() {\n    return Err(anyhow!(\"source '{}' is not a directory\", src.display()));\n}","typeGuard":"fn is_zipable_dir(p: &Path) -> bool { p.is_dir() }","tryCatchPattern":"match create_zip_file_from_dir(&src, &dst).await {\n    Ok(path) => println!(\"zip at {}\", path.display()),\n    Err(e) if e.to_string().contains(\"is not a directory\") => {\n        std::fs::create_dir_all(&src)?;\n        // retry once\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure the logs/repository directories exist before zipping","Resolve and canonicalize paths before passing them in","Never pass a file path where a directory is expected"],"tags":["filesystem","zip","path","validation"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}