{"record":{"id":"7fb5b7a81f6cf261","repo":"flxzt/rnote","slug":"expected-file-found-directory","errorCode":null,"errorMessage":"Expected file, found directory \"{}\"","messagePattern":"Expected file, found directory \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-cli/src/validators.rs","lineNumber":15,"sourceCode":"use std::path::Path;\n\npub(crate) fn path_is_dir(path: &Path) -> anyhow::Result<()> {\n    if !path.is_dir() {\n        return Err(anyhow::anyhow!(\n            \"Expected directory, found file \\\"{}\\\"\",\n            path.display()\n        ));\n    }\n    Ok(())\n}\n\npub(crate) fn path_is_file(path: &Path) -> anyhow::Result<()> {\n    if !path.is_file() {\n        return Err(anyhow::anyhow!(\n            \"Expected file, found directory \\\"{}\\\"\",\n            path.display()\n        ));\n    }\n    Ok(())\n}\n\npub(crate) fn file_has_ext(path: &Path, expected_ext: &str) -> anyhow::Result<()> {\n    path_is_file(path)?;\n    match path.extension() {\n        Some(ext) if ext == expected_ext => Ok(()),\n        Some(ext) => Err(anyhow::anyhow!(\n            \"Expected file with extension \\\"{expected_ext}\\\", found extension \\\"{ext:?}\\\", file \\\"{}\\\".\",\n            path.display()\n        )),\n        None => Err(anyhow::anyhow!(\n            \"Expected file with extension \\\"{expected_ext}\\\", no extension found for file \\\"{}\\\".\",\n            path.display()","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-cli/src/validators.rs#L1-L33","documentation":"Sentinel validation guard in path_is_file: the given path exists but is a directory, not a regular file, so it fails the file-type check. Fires whenever a CLI argument expected to be a file (e.g. an .rnote input) resolves to a directory.","triggerScenarios":"Passing a directory or nonexistent path to an argument validated with path_is_file, such as the input .rnote or .xopp file path.","commonSituations":"Tab-completion selecting the parent directory; expecting the tool to create the file; typos in the file name.","solutions":["Pass the path to the actual file, not its containing directory","Verify the file exists (ls / Path::is_file) before running the command","Fix the typo or path in scripts; note the tool will not create missing inputs"],"exampleFix":"// before\nrnote-cli export --rnote-file ./notes/\n// after\nrnote-cli export --rnote-file ./notes/sketch.rnote","handlingStrategy":"validation","validationCode":"let p = std::path::Path::new(input);\nif !p.is_file() {\n    eprintln!(\"{} is not a regular file\", input);\n    std::process::exit(2);\n}","typeGuard":"fn is_existing_file(p: &Path) -> bool {\n    p.is_file()\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Expected file, found directory\") => {\n        eprintln!(\"Input must be a file, not a directory; check the path\");\n    }\n    other => other,\n}","preventionTips":["Verify input paths point to real files before invoking","Avoid tab-completing to directories for file arguments","Check for typos in file names"],"tags":["validation","filesystem","cli"],"backgroundTag":"file-not-found","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}