tonhowtf/omniget · error · anyhow::Error

nenhuma operação escolhida

Error message

nenhuma operação escolhida

What it means

clean_one builds a filter chain from the selected mode; if neither denoise nor loudness produced a filter (mode not in {denoise, loudness, both} or equivalent), the chain is empty and it errors with "nenhuma operação escolhida". This is a guard against running ffmpeg with an empty -af argument.

Solutions

  1. Set opts.mode to one of the supported values (denoise | loudness | both)
  2. Validate the mode string when constructing CleanOptions and reject unknown values early
  3. Log the incoming mode value to spot client/config mismatches
  4. Add an exhaustive match on mode so unknown values fail at parse time

Example fix

// before
if chain.is_empty() {
    return Err(anyhow!("nenhuma operação escolhida"));
}
// after
if chain.is_empty() {
    return Err(anyhow!("nenhuma operação escolhida: modo inválido '{}', use 'denoise', 'loudness' ou 'both'", opts.mode));
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate the mode before constructing CleanOptions
const VALID_MODES: [&str; 3] = ["denoise", "loudness", "both"];
anyhow::ensure!(VALID_MODES.contains(&opts.mode.as_str()), "invalid mode '{}' — expected denoise|loudness|both", opts.mode);

Try / catch

match clean_one(&ffmpeg, &opts, &input).await {
    Err(e) if e.to_string().contains("nenhuma operação escolhida") => {
        return Err(anyhow!("no cleaning mode selected; set mode to denoise, loudness or both"));
    }
    other => other,
}

Prevention

When it happens

Trigger: run -> clean_one with CleanOptions.mode set to an unrecognized string or left empty, so neither the loudness nor denoise branch pushes a filter.

Common situations: Typo in mode value (e.g. "normalise" vs "loudness"); mode field not populated from UI/config; new mode added upstream but not mapped in clean_one.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/ca4a656329ddf294. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/audio_clean.rs:200

        .any(|s| s.codec_type == "video" && s.codec_name != "mjpeg" && s.codec_name != "png");
    let (target_i, target_tp) = target_for(&opts.target);

    let mut chain: Vec<String> = Vec::new();
    let mut measured = None;
    if opts.mode == "denoise" || opts.mode == "both" {
        chain.push(denoise_filter(
            &opts.denoise_mode,
            opts.strength,
            (!opts.rnnn_path.trim().is_empty()).then_some(opts.rnnn_path.trim()),
        ));
    }
    if opts.mode == "loudness" || opts.mode == "both" {
        let m = measure(ffmpeg, inp, &measure_filter(target_i, target_tp)).await?;
        chain.push(apply_filter(&m, target_i, target_tp));
        measured = Some(m);
    }
    if chain.is_empty() {
        return Err(anyhow!("nenhuma operação escolhida"));
    }
    let filter = chain.join(",");

    let out_dir = if opts.output_dir.trim().is_empty() {
        inp.parent().map(|p| p.to_path_buf()).unwrap_or_default()
    } else {
        PathBuf::from(opts.output_dir.trim())
    };
    std::fs::create_dir_all(&out_dir)?;
    let stem = inp
        .file_stem()
        .map(|s| s.to_string_lossy().to_string())
        .unwrap_or_else(|| "audio".into());
    let ext = if has_video {
        inp.extension()
            .map(|e| e.to_string_lossy().to_string())
            .unwrap_or_else(|| "mp4".into())
    } else if opts.audio_format.trim().is_empty() {

View on GitHub (pinned to 8600b91f42)