{"record":{"id":"39bb430d7e10fde8","repo":"tonhowtf/omniget","slug":"escolha-ao-menos-uma-imagem","errorCode":null,"errorMessage":"escolha ao menos uma imagem","messagePattern":"escolha ao menos uma imagem","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/img_bg.rs","lineNumber":413,"sourceCode":"    let (ow, oh) = (img.width(), img.height());\n    Ok(image::imageops::resize(\n        &small,\n        ow,\n        oh,\n        FilterType::Lanczos3,\n    ))\n}\n\nfn run_blocking(\n    opts: &BgOptions,\n    model_id: &str,\n    progress: &ProgressFn,\n) -> anyhow::Result<BgResult> {\n    let params = *params_for(model_id)\n        .ok_or_else(|| anyhow!(\"o modelo {model_id} não serve para remover fundo\"))?;\n    let files = collect_inputs(&opts.inputs, &opts.input_dir);\n    if files.is_empty() {\n        return Err(anyhow!(\"escolha ao menos uma imagem\"));\n    }\n    let background = parse_hex_color(&opts.background)?;\n    let ext = resolve_format(&opts.format, background.is_some(), opts.mask_only);\n\n    let mut session = super::onnx::session_for(model_id)?;\n    let total = files.len() as u64;\n    let mut items: Vec<BgItem> = Vec::with_capacity(files.len());\n    let mut failed = 0usize;\n\n    for (i, path) in files.iter().enumerate() {\n        super::report(\n            progress,\n            TOOL_ID,\n            \"progress\",\n            i as u64,\n            Some(total),\n            Some(path.to_string_lossy().to_string()),\n        );","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/img_bg.rs#L395-L431","documentation":"img_bg's run_blocking collects the input image paths from opts.inputs and opts.input_dir before starting background removal. If the resulting list is empty it refuses to proceed, since removing a background from nothing is meaningless. The library throws this early validation error instead of creating an ONNX session or spawning work on empty input.","triggerScenarios":"Calling run (via run_blocking) with an opts where both opts.inputs is empty/absent and opts.input_dir points to a nonexistent or empty directory, so collect_inputs returns an empty Vec.","commonSituations":"CLI/Tauri frontend launched without selecting files; input_dir typo or empty folder; user cleared the file list in the UI before submitting.","solutions":["Populate opts.inputs with at least one image path before calling run","Point opts.input_dir at a directory that exists and contains image files","Check collect_inputs results (file existence, extension filters) for why inputs were dropped"],"exampleFix":"// before\nBgOptions { inputs: vec![], input_dir: None, .. }\n// after\nBgOptions { inputs: vec![\"photo.png\".into()], input_dir: None, .. }","handlingStrategy":"validation","validationCode":"let files: Vec<_> = collect_inputs(&opts.inputs, &opts.input_dir);\nif files.is_empty() {\n    return Err(anyhow!(\"escolha ao menos uma imagem\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set either inputs or input_dir before calling run","Verify the input directory is non-empty and contains supported image extensions","In UIs, disable the submit button until at least one file is selected"],"tags":["rust","validation","empty-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"}