{"record":{"id":"077462f827f28369","repo":"tonhowtf/omniget","slug":"texto-vazio","errorCode":null,"errorMessage":"texto vazio","messagePattern":"texto vazio","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/omniget-core/src/core/tools/edge_tts.rs","lineNumber":366,"sourceCode":"            if buf.len() >= 8 || gap > 600 {\n                flush(&mut buf, &mut cues);\n            }\n        }\n        buf.push(w);\n    }\n    flush(&mut buf, &mut cues);\n    cues\n}\n\n/// Sintetiza `opts.text` inteiro em `audio_path` (MP3) e escreve o SRT ao lado.\npub async fn synthesize(\n    opts: TtsOptions,\n    audio_path: &std::path::Path,\n    progress: super::ProgressFn,\n) -> anyhow::Result<TtsResult> {\n    let chunks = split_text(&opts.text);\n    if chunks.is_empty() {\n        return Err(anyhow!(\"texto vazio\"));\n    }\n    let id = format!(\"tts:{}\", audio_path.display());\n    let mut audio = Vec::new();\n    let mut words: Vec<WordBoundary> = Vec::new();\n    let mut offset_ms: u64 = 0;\n    let mut skew: i64 = 0;\n    for (i, chunk) in chunks.iter().enumerate() {\n        super::report(\n            &progress,\n            &id,\n            \"synthesize\",\n            i as u64,\n            Some(chunks.len() as u64),\n            None,\n        );\n        let out = match synth_chunk(chunk, &opts, skew).await {\n            Ok(o) => o,\n            Err(e) => {","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/edge_tts.rs#L348-L384","documentation":"synthesize splits opts.text into chunks via split_text; if the result is empty the function cannot produce any audio and throws this error immediately. It is an input-validation guard meaning no synthesizable text was supplied.","triggerScenarios":"Calling synthesize() with TtsOptions.text being empty, whitespace-only, or containing only characters that split_text strips out.","commonSituations":"Empty string field in UI/config; text extracted from a document that turned out to be blank; accidental whitespace-only input; caller forgetting to set opts.text before invoking synthesize.","solutions":["Ensure opts.text is non-empty and contains real characters before calling synthesize","Trim and validate user input at the application boundary","Return a friendly validation message to the user instead of letting the backend fail"],"exampleFix":"// before\nedge_tts::synthesize(&TtsOptions { text: user_text, ..opts }, &path, progress).await?;\n// after\nlet text = user_text.trim();\nif text.is_empty() {\n    return Err(anyhow!(\"informe um texto para sintetizar\"));\n}\nedge_tts::synthesize(&TtsOptions { text: text.to_string(), ..opts }, &path, progress).await?;","handlingStrategy":"validation","validationCode":"if opts.text.trim().is_empty() {\n    return Err(anyhow!(\"texto para TTS nao pode ser vazio\"));\n}","typeGuard":null,"tryCatchPattern":"match edge_tts::synthesize(&opts, &path, progress).await {\n    Ok(r) => r,\n    Err(e) if e.to_string() == \"texto vazio\" => { user_facing_error(\"informe um texto\"); Default::default() }\n    Err(e) => return Err(e),\n}","preventionTips":["Always trim and check text length before calling synthesize","Validate form/UI inputs at the boundary","Filter out whitespace-only or stripped-only content before queuing TTS jobs"],"tags":["validation","input","edge-tts","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"}