{"record":{"id":"b325dfe6cbf4e1db","repo":"tonhowtf/omniget","slug":"resposta-vazia","errorCode":null,"errorMessage":"resposta vazia","messagePattern":"resposta vazia","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/voicestudio.rs","lineNumber":202,"sourceCode":"    } else {\n        crate::core::process::command(&app).spawn()?;\n    }\n    Ok(())\n}\n\nasync fn wav_from(resp: reqwest::Response, output: &Path) -> anyhow::Result<PathBuf> {\n    let status = resp.status();\n    if !status.is_success() {\n        let text = resp.text().await.unwrap_or_default();\n        return Err(anyhow!(\n            \"VoiceStudio HTTP {}: {}\",\n            status.as_u16(),\n            text.chars().take(300).collect::<String>()\n        ));\n    }\n    let bytes = resp.bytes().await?;\n    if bytes.len() < 100 {\n        return Err(anyhow!(\"resposta vazia\"));\n    }\n    if let Some(parent) = output.parent() {\n        std::fs::create_dir_all(parent)?;\n    }\n    std::fs::write(output, &bytes)?;\n    Ok(output.to_path_buf())\n}\n\nfn stamp() -> String {\n    chrono::Local::now().format(\"%Y%m%d-%H%M%S\").to_string()\n}\n\nfn out_path(output_dir: &str, name: &str) -> PathBuf {\n    let dir = if output_dir.trim().is_empty() {\n        dirs::audio_dir()\n            .or_else(dirs::home_dir)\n            .unwrap_or_default()\n            .join(\"OmniGet\")","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/voicestudio.rs#L184-L220","documentation":"After a successful HTTP status, wav_from reads the response bytes and rejects any body smaller than 100 bytes as 'resposta vazia' (empty response), since valid WAV audio is always larger. This catches servers that return 200 with an empty or trivially small body instead of real audio.","triggerScenarios":"VoiceStudio returns HTTP 200 but the body is empty, an HTML error page, or a stub/placeholder smaller than 100 bytes during clone_speak, design_speak, or isolate.","commonSituations":"A proxy or gateway returning a 200 with an empty body after a timeout, misconfigured VoiceStudio endpoint returning JSON instead of WAV, or silent synthesis failure where the server acknowledges but produces no audio.","solutions":["Inspect the actual response body (<100 bytes) to see whether it's empty, HTML, or a JSON error message.","Verify the request produced real work server-side (check VoiceStudio logs for the synthesis job).","Confirm the endpoint URL is the audio-producing route and not a status/metadata route.","Retry the request; transient gateway issues can produce empty 200 responses.","If the server legitimately returns short payloads (e.g. tiny valid files), lower or parameterize the 100-byte threshold."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// After any VoiceStudio call that should return audio, verify size before saving\nif let Ok(meta) = std::fs::metadata(&output_path) {\n    if meta.len() < 100 {\n        return Err(\"VoiceStudio returned no audio data\".into());\n    }\n}","typeGuard":"fn is_plausible_wav(bytes: &[u8]) -> bool {\n    bytes.len() >= 100 && bytes.starts_with(b\"RIFF\") && bytes.len() >= 12 && &bytes[8..12] == b\"WAVE\"\n}","tryCatchPattern":"match wav_result {\n    Err(e) if e.to_string() == \"resposta vazia\" => {\n        // retry once, then fall back to an alternate endpoint or report no-audio\n    }\n    other => other?,\n}","preventionTips":["Confirm the endpoint returns raw WAV bytes, not JSON/metadata.","Log small/empty 200 bodies to detect proxy or gateway interference.","Retain and inspect the raw body when validation fails, for diagnostics.","Add a WAV 'RIFF' header check in addition to the size check for stronger validation."],"tags":["http","empty-response","audio","rust"],"backgroundTag":"empty-response-body","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"}