tonhowtf/omniget · error
escolha o PDF
Error message
escolha o PDF
What it means
Guard in pdf_table::scan: the caller passed an input PDF path that is empty or whitespace-only, so there is nothing to scan for tables. The function returns early instead of attempting to open a bogus path.
Solutions
- Pass a real path to an existing PDF in Options.input before calling scan
- Validate/trim the input path at the call site and surface a user-facing 'select a PDF' message instead of invoking the tool
- Check upstream code for where Options.input is populated (dialog result, CLI arg) — an empty string usually means the selection step was skipped
Example fix
// before
let opts = Options { input: picked_path.unwrap_or_default(), .. };
pdf_table::scan(&opts, &progress)?;
// after
let picked = picked_path.filter(|p| !p.trim().is_empty());
let Some(path) = picked else { anyhow::bail!("escolha o PDF"); };
let opts = Options { input: path, .. }; Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate before calling scan
fn ensure_pdf_chosen(opts: &pdf_table::Options) -> anyhow::Result<()> {
if opts.input.trim().is_empty() { anyhow::bail!("escolha o PDF"); }
let p = std::path::Path::new(opts.input.trim());
if !p.is_file() { anyhow::bail!("arquivo não existe: {}", opts.input); }
Ok(())
} Type guard
fn has_input(opts: &pdf_table::Options) -> bool {
!opts.input.trim().is_empty()
} Try / catch
match pdf_table::scan(&opts, &progress) {
Err(e) if e.to_string() == "escolha o PDF" => {
// surface file-picker dialog / usage message to the user
prompt_user_for_pdf()?;
}
other => other?,
} Prevention
- Validate Options.input (non-empty, file exists) right after collecting it from UI/CLI/config
- Never unwrap_or_default() a file-picker result into the input field
- Require an explicit input flag in CLI wrappers so omission fails fast with usage help
- Trim user-supplied paths before storing them in Options
When it happens
Trigger: Calling scan(&Options { input: "".into() | " ".into(), .. }, progress) — typically because the field was never filled, a form dialog was cancelled, or an empty String defaulted in.
Common situations: Frontend sends an empty input field; config/CLI flag for the PDF omitted; variable holding the path was overwritten with ""; user picked no file but the tool was invoked anyway.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- escolha a pasta de destino para organizar
- escolha a pasta de destino
- escolha a pasta de destino
- nenhuma imagem
- nenhuma pagina selecionada
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/b166dfa0beb15438.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf_table.rs:255
.unwrap_or_default()
} else {
PathBuf::from(output_dir.trim())
};
std::fs::create_dir_all(&dir)?;
Ok(dir)
}
fn stem(input: &str) -> String {
Path::new(input.trim())
.file_stem()
.map(|s| super::sanitize_name(&s.to_string_lossy()))
.unwrap_or_else(|| "documento".into())
}
/// Acha as tabelas do documento sem gravar nada.
pub fn scan(opts: &Options, progress: &super::ProgressFn) -> anyhow::Result<Vec<Table>> {
if opts.input.trim().is_empty() {
return Err(anyhow!("escolha o PDF"));
}
let password = if opts.password.is_empty() {
None
} else {
Some(opts.password.as_str())
};
let min_gap = if opts.min_gap <= 0.0 {
5.0
} else {
opts.min_gap
};
let min_rows = opts.min_rows.max(2);
let min_cols = opts.min_cols.max(2);
let progress2 = progress.clone();
let pages = pdf::read_pages(
&opts.input,
password,View on GitHub (pinned to 8600b91f42)