tonhowtf/omniget · error · anyhow::Error

nenhuma tentativa rodou

Error message

nenhuma tentativa rodou

What it means

After the quality-ladder loop, convert_one unwraps `best` with ok_or_else; if the loop body never executed even once, there is no candidate output at all, so it throws "nenhuma tentativa rodou" (no attempt ran). This is an internal invariant violation — the ladder is expected to contain at least one quality step.

Solutions

  1. Inspect how the StickerSpec passed to convert_one is built and ensure its quality ladder is non-empty
  2. Add an assertion/default fallback quality step when constructing the spec
  3. File/fix an internal bug — this error should be unreachable with valid specs

Example fix

// before
let (bytes, attempt) = best.ok_or_else(|| anyhow!("nenhuma tentativa rodou"))?;
// after
let (bytes, attempt) = best.unwrap_or_else(|| panic!("quality ladder must not be empty"));
Defensive patterns

Strategy: try-catch

Validate before calling

if spec.qualities().is_empty() { return Err("sticker spec has an empty quality ladder"); }

Try / catch

match convert_one(&input, &output, &spec).await {
    Err(e) if e.to_string().contains("nenhuma tentativa rodou") => {
        // internal bug: report and rebuild spec with default quality ladder
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling convert_one when the ladder/quality spec yields zero attempts (empty quality list in the spec), so the for loop over attempts never runs and `best` stays None.

Common situations: A misconfigured or partially-built StickerSpec with an empty quality ladder; future code changes filtering out all attempts; construction of the attempts list failing silently upstream.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/sticker.rs:510

            // bom na mão, então vale ficar com ele.
            if best.is_none() {
                return Err(anyhow!("{}", msg));
            }
            tracing::warn!(
                "[wa-sticker] tentativa q{} falhou: {}",
                attempt.quality,
                msg
            );
            break;
        }
        let bytes = std::fs::metadata(&output).map(|m| m.len()).unwrap_or(0);
        best = Some((bytes, attempt));
        if bytes <= spec.max_bytes {
            break;
        }
    }

    let (bytes, attempt) = best.ok_or_else(|| anyhow!("nenhuma tentativa rodou"))?;
    Ok(StickerItem {
        input: input.to_string(),
        output: Some(output.to_string_lossy().to_string()),
        animated,
        bytes,
        max_bytes: spec.max_bytes,
        size: spec.size,
        duration_s: if animated { secs } else { 0.0 },
        quality: attempt.quality,
        fps: attempt.fps,
        tries,
        hit_target: bytes <= spec.max_bytes,
        ok: true,
        error: None,
    })
}

/// Bandeja do pacote: 96×96 PNG, o que o WhatsApp pede.

View on GitHub (pinned to 8600b91f42)