{"record":{"id":"734d6e161ee59bc3","repo":"tonhowtf/omniget","slug":"escolha-um-pdf","errorCode":null,"errorMessage":"escolha um PDF","messagePattern":"escolha um PDF","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_markdown.rs","lineNumber":1052,"sourceCode":"    let dir = path.parent().map(Path::to_path_buf).unwrap_or_default();\n    let base = stem(&path);\n    let ext = path\n        .extension()\n        .map(|e| format!(\".{}\", e.to_string_lossy()))\n        .unwrap_or_default();\n    for n in 2..1000 {\n        let cand = dir.join(format!(\"{} ({}){}\", base, n, ext));\n        if !cand.exists() {\n            return cand;\n        }\n    }\n    path\n}\n\npub fn run(opts: &Options, progress: &ProgressFn) -> anyhow::Result<MdResult> {\n    let input = opts.input.trim();\n    if input.is_empty() {\n        return Err(anyhow!(\"escolha um PDF\"));\n    }\n    let path = PathBuf::from(input);\n    super::report(progress, ID, \"read\", 0, None, Some(\"PDF\".into()));\n    let pages: Vec<PageText> = pdf::read_pages(\n        input,\n        opts.password.as_deref().filter(|p| !p.is_empty()),\n        &opts.pages,\n        opts.extract_images,\n        |done, total| {\n            super::report(\n                progress,\n                ID,\n                \"read\",\n                done as u64,\n                Some(total as u64),\n                Some(format!(\"{}/{}\", done, total)),\n            );\n        },","sourceCodeStart":1034,"sourceCodeEnd":1070,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_markdown.rs#L1034-L1070","documentation":"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.","triggerScenarios":"Calling run(&opts, ...) with opts.input == \"\" or \"   \".","commonSituations":"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.","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"],"exampleFix":"// before\nlet opts = Options { input: String::new(), .. };\nrun(&opts, &progress)?;\n// after\nlet opts = Options { input: picked_path.clone(), .. };\nif picked_path.is_empty() { bail!(\"select a PDF first\"); }\nrun(&opts, &progress)?;","handlingStrategy":"validation","validationCode":"if opts.input.trim().is_empty() { bail!(\"select a PDF\"); }","typeGuard":"fn has_input(o: &Options) -> bool { !o.input.trim().is_empty() }","tryCatchPattern":null,"preventionTips":["Require the file picker before enabling the command","Trim user-supplied paths","Add an empty-input unit test"],"tags":["pdf","validation","input"],"backgroundTag":"empty-required-field","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}