{"record":{"id":"f75301e7c7c2b608","repo":"flxzt/rnote","slug":"expected-file-with-extension-expected-ext-no","errorCode":null,"errorMessage":"Expected file with extension \"{expected_ext}\", no extension found for file \"{}\".","messagePattern":"Expected file with extension \"(.+?)\", no extension found for file \"(.+?)\"\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-cli/src/validators.rs","lineNumber":31,"sourceCode":"pub(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()\n        )),\n    }\n}\n","sourceCodeStart":13,"sourceCodeEnd":37,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-cli/src/validators.rs#L13-L37","documentation":"Validation error in file_has_ext: after confirming the path is a file, path.extension() returned None, meaning the file name has no extension at all while the caller required one (e.g. \"rnote\"). Fires when a path like `mynote` is passed where an .rnote file is expected.","triggerScenarios":"Passing an extensionless file (e.g. 'drawing', a temp file, or a dotfile) where a specific extension like '.xopp' is validated.","commonSituations":"Files downloaded by curl without names; editor temp/backup files; paths stripped of extensions by scripts.","solutions":["Rename the file to include the expected extension (mv drawing drawing.xopp)","Re-download/re-export the file properly named","Guard scripts: skip or rename files whose Path::extension() is None before invoking the CLI"],"exampleFix":"// before\nrnote-cli import /tmp/download-1234 out.rnote\n// after\nmv /tmp/download-1234 /tmp/download-1234.xopp && rnote-cli import /tmp/download-1234.xopp out.rnote","handlingStrategy":"validation","validationCode":"fn has_any_ext(p: &Path) -> bool {\n    p.extension().is_some()\n}\nif !has_any_ext(Path::new(input)) { eprintln!(\"input file has no extension\"); }","typeGuard":"fn is_extensionless(p: &Path) -> bool {\n    p.extension().is_none()\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"no extension found\") => {\n        eprintln!(\"Rename the input so it has the expected extension\");\n    }\n    other => other,\n}","preventionTips":["Name downloads properly when saving (curl -o file.xopp)","Skip or rename temp/backup files lacking extensions before batch processing","Validate extensions in batch scripts before invoking the CLI"],"tags":["validation","file-extension","cli"],"backgroundTag":"invalid-argument-format","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}