{"record":{"id":"cc021800550413d1","repo":"tonhowtf/omniget","slug":"nenhuma-tentativa-rodou","errorCode":null,"errorMessage":"nenhuma tentativa rodou","messagePattern":"nenhuma tentativa rodou","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/sticker.rs","lineNumber":510,"sourceCode":"            // bom na mão, então vale ficar com ele.\n            if best.is_none() {\n                return Err(anyhow!(\"{}\", msg));\n            }\n            tracing::warn!(\n                \"[wa-sticker] tentativa q{} falhou: {}\",\n                attempt.quality,\n                msg\n            );\n            break;\n        }\n        let bytes = std::fs::metadata(&output).map(|m| m.len()).unwrap_or(0);\n        best = Some((bytes, attempt));\n        if bytes <= spec.max_bytes {\n            break;\n        }\n    }\n\n    let (bytes, attempt) = best.ok_or_else(|| anyhow!(\"nenhuma tentativa rodou\"))?;\n    Ok(StickerItem {\n        input: input.to_string(),\n        output: Some(output.to_string_lossy().to_string()),\n        animated,\n        bytes,\n        max_bytes: spec.max_bytes,\n        size: spec.size,\n        duration_s: if animated { secs } else { 0.0 },\n        quality: attempt.quality,\n        fps: attempt.fps,\n        tries,\n        hit_target: bytes <= spec.max_bytes,\n        ok: true,\n        error: None,\n    })\n}\n\n/// Bandeja do pacote: 96×96 PNG, o que o WhatsApp pede.","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/sticker.rs#L492-L528","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect how the StickerSpec passed to convert_one is built and ensure its quality ladder is non-empty","Add an assertion/default fallback quality step when constructing the spec","File/fix an internal bug — this error should be unreachable with valid specs"],"exampleFix":"// before\nlet (bytes, attempt) = best.ok_or_else(|| anyhow!(\"nenhuma tentativa rodou\"))?;\n// after\nlet (bytes, attempt) = best.unwrap_or_else(|| panic!(\"quality ladder must not be empty\"));","handlingStrategy":"try-catch","validationCode":"if spec.qualities().is_empty() { return Err(\"sticker spec has an empty quality ladder\"); }","typeGuard":null,"tryCatchPattern":"match convert_one(&input, &output, &spec).await {\n    Err(e) if e.to_string().contains(\"nenhuma tentativa rodou\") => {\n        // internal bug: report and rebuild spec with default quality ladder\n    }\n    other => other,\n}","preventionTips":["Never build a StickerSpec with an empty quality list","Add a debug_assert! on the ladder length at construction","Cover spec construction with unit tests"],"tags":["rust","anyhow","invariant","sticker","internal-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}