{"record":{"id":"eae0e30fa655b34f","repo":"flxzt/rnote","slug":"failed-to-get-file-stem-from-rnote-file","errorCode":null,"errorMessage":"Failed to get file stem from rnote file \"{}\"","messagePattern":"Failed to get file stem from rnote file \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-cli/src/export.rs","lineNumber":599,"sourceCode":"        }\n        cli::ExportCommand::DocPages {\n            output_dir,\n            output_file_stem,\n            export_format: output_format,\n            ..\n        } => {\n            validators::path_is_dir(output_dir)?;\n            // The output file cannot be set with this subcommand\n            drop(output_file);\n\n            let pages_export_bytes = engine.export_doc_pages(None).await??;\n            let out_ext = output_format.file_ext();\n            let output_file_stem = match output_file_stem {\n                Some(o) => o.clone(),\n                None => match rnote_file.as_ref().file_stem() {\n                    Some(stem) => stem.to_string_lossy().to_string(),\n                    None => {\n                        return Err(anyhow::anyhow!(\n                            \"Failed to get file stem from rnote file \\\"{}\\\"\",\n                            rnote_file.as_ref().display()\n                        ));\n                    }\n                },\n            };\n            let pages_amount = pages_export_bytes.len();\n            for (page_i, bytes) in pages_export_bytes.into_iter().enumerate() {\n                let output_file = doc_page_determine_output_file(\n                    page_i,\n                    pages_amount,\n                    output_dir,\n                    &out_ext,\n                    &output_file_stem,\n                    on_conflict,\n                    on_conflict_overwrite,\n                )?;\n                cli::create_overwrite_file_w_bytes(&output_file, &bytes)","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-cli/src/export.rs#L581-L617","documentation":"export_to_file could not derive the output file stem from the input .rnote file when no explicit stem was supplied. Path::file_stem() returns None for paths ending in '..' or the root, so the command aborts rather than inventing a name.","triggerScenarios":"Running an export command without the optional output file stem argument, with the input rnote_file path being '/', ending in '..', or otherwise having no final path component.","commonSituations":"Piping a root or relative '..' path into --rnote-file; templated scripts that substitute an empty or degenerate input path.","solutions":["Provide the output file stem explicitly via the CLI argument instead of relying on derivation from the input path","Pass a valid input .rnote file path with a real file name","Sanitize/validate the input path in scripts (reject paths whose file_stem() is None)"],"exampleFix":"// before\nrnote-cli export --rnote-file ../..\n// after\nrnote-cli export --rnote-file notes/sketch.rnote --output-file-stem sketch","handlingStrategy":"validation","validationCode":"if rnote_file.file_stem().is_none() {\n    eprintln!(\"rnote file path must have a file name/stem\");\n    std::process::exit(2);\n}","typeGuard":"fn has_stem(p: &Path) -> bool {\n    p.file_stem().is_some()\n}","tryCatchPattern":"match run_result {\n    Err(e) if e.to_string().contains(\"Failed to get file stem\") => {\n        eprintln!(\"Pass --output-file-stem or a valid input file path\");\n    }\n    other => other,\n}","preventionTips":["Supply the optional output stem argument explicitly in scripts","Validate input paths end in '<name>.rnote' before invoking","Reject root or '..'-terminated paths in wrappers"],"tags":["cli","path","filesystem"],"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-16T09:17:16.951Z"}