tonhowtf/omniget · error
escolha um PDF
Error message
escolha um PDF
What it means
A validation guard in pdf_markdown's run(): the Options.input field is empty (or only whitespace) after trimming, so there is no PDF to convert and the function fails fast with this Portuguese message.
Solutions
- Set opts.input to the PDF file path before calling run
- Validate/require the file picker result in the UI before invoking the command
- Reject empty input at the API boundary with a clearer message
Example fix
// before
let opts = Options { input: String::new(), .. };
run(&opts, &progress)?;
// after
let opts = Options { input: picked_path.clone(), .. };
if picked_path.is_empty() { bail!("select a PDF first"); }
run(&opts, &progress)?; Defensive patterns
Strategy: validation
Validate before calling
if opts.input.trim().is_empty() { bail!("select a PDF"); } Type guard
fn has_input(o: &Options) -> bool { !o.input.trim().is_empty() } Prevention
- Require the file picker before enabling the command
- Trim user-supplied paths
- Add an empty-input unit test
When it happens
Trigger: Calling run(&opts, ...) with opts.input == "" or " ".
Common situations: Frontend invoked the command before the user picked a file; an Options struct built programmatically with a forgotten input field; a drag-and-drop handler passing an empty path.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/734d6e161ee59bc3.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf_markdown.rs:1052
let dir = path.parent().map(Path::to_path_buf).unwrap_or_default();
let base = stem(&path);
let ext = path
.extension()
.map(|e| format!(".{}", e.to_string_lossy()))
.unwrap_or_default();
for n in 2..1000 {
let cand = dir.join(format!("{} ({}){}", base, n, ext));
if !cand.exists() {
return cand;
}
}
path
}
pub fn run(opts: &Options, progress: &ProgressFn) -> anyhow::Result<MdResult> {
let input = opts.input.trim();
if input.is_empty() {
return Err(anyhow!("escolha um PDF"));
}
let path = PathBuf::from(input);
super::report(progress, ID, "read", 0, None, Some("PDF".into()));
let pages: Vec<PageText> = pdf::read_pages(
input,
opts.password.as_deref().filter(|p| !p.is_empty()),
&opts.pages,
opts.extract_images,
|done, total| {
super::report(
progress,
ID,
"read",
done as u64,
Some(total as u64),
Some(format!("{}/{}", done, total)),
);
},View on GitHub (pinned to 8600b91f42)