flxzt/rnote · error

Expected file with extension

Error message

Expected file with extension "{expected_ext}", no extension found for file "{}".

What it means

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.

Solutions

  1. Rename the file to include the expected extension (mv drawing drawing.xopp)
  2. Re-download/re-export the file properly named
  3. Guard scripts: skip or rename files whose Path::extension() is None before invoking the CLI

Example fix

// before
rnote-cli import /tmp/download-1234 out.rnote
// after
mv /tmp/download-1234 /tmp/download-1234.xopp && rnote-cli import /tmp/download-1234.xopp out.rnote
Defensive patterns

Strategy: validation

Validate before calling

fn has_any_ext(p: &Path) -> bool {
    p.extension().is_some()
}
if !has_any_ext(Path::new(input)) { eprintln!("input file has no extension"); }

Type guard

fn is_extensionless(p: &Path) -> bool {
    p.extension().is_none()
}

Try / catch

match result {
    Err(e) if e.to_string().contains("no extension found") => {
        eprintln!("Rename the input so it has the expected extension");
    }
    other => other,
}

Prevention

When it happens

Trigger: Passing an extensionless file (e.g. 'drawing', a temp file, or a dotfile) where a specific extension like '.xopp' is validated.

Common situations: Files downloaded by curl without names; editor temp/backup files; paths stripped of extensions by scripts.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/f75301e7c7c2b608. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-cli/src/validators.rs:31

pub(crate) fn path_is_file(path: &Path) -> anyhow::Result<()> {
    if !path.is_file() {
        return Err(anyhow::anyhow!(
            "Expected file, found directory \"{}\"",
            path.display()
        ));
    }
    Ok(())
}

pub(crate) fn file_has_ext(path: &Path, expected_ext: &str) -> anyhow::Result<()> {
    path_is_file(path)?;
    match path.extension() {
        Some(ext) if ext == expected_ext => Ok(()),
        Some(ext) => Err(anyhow::anyhow!(
            "Expected file with extension \"{expected_ext}\", found extension \"{ext:?}\", file \"{}\".",
            path.display()
        )),
        None => Err(anyhow::anyhow!(
            "Expected file with extension \"{expected_ext}\", no extension found for file \"{}\".",
            path.display()
        )),
    }
}

View on GitHub (pinned to bbc5354502)