{"record":{"id":"6f3e2f35ade52be2","repo":"tonhowtf/omniget","slug":"o-yt-dlp-saiu-com-erro","errorCode":null,"errorMessage":"o yt-dlp saiu com erro","messagePattern":"o yt-dlp saiu com erro","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/yt_archive.rs","lineNumber":693,"sourceCode":"    let err_task = tokio::spawn(async move {\n        let mut tail: Vec<String> = Vec::new();\n        if let Some(e) = stderr {\n            let mut lines = BufReader::new(e).lines();\n            while let Ok(Some(line)) = lines.next_line().await {\n                if tail.len() == 3 {\n                    tail.remove(0);\n                }\n                tail.push(line);\n            }\n        }\n        tail.join(\" / \")\n    });\n\n    let status = child.wait().await?;\n    let file = out_task.await.unwrap_or(None);\n    let tail = err_task.await.unwrap_or_default();\n    if !status.success() {\n        return Err(anyhow!(\n            \"{}\",\n            if tail.trim().is_empty() {\n                \"o yt-dlp saiu com erro\".to_string()\n            } else {\n                tail\n            }\n        ));\n    }\n    Ok(file)\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    const FLAT: &str = r#\"{\n      \"_type\": \"playlist\",\n      \"id\": \"PL123\",","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/yt_archive.rs#L675-L711","documentation":"yt-dlp spawned successfully but exited with a non-zero status code. If the collected stderr tail is empty, this generic message is used; otherwise the actual stderr tail is returned as the error. It indicates the download itself failed (network, 403, format unavailable, etc.).","triggerScenarios":"`download_one` waits on `child.wait().await`, sees `!status.success()`, and stderr produced no useful text (empty tail) so the fallback message is thrown.","commonSituations":"yt-dlp crashing before printing anything; killed by signal; stderr not captured due to pipe issue; very old yt-dlp version failing silently against current YouTube.","solutions":["Update yt-dlp to the latest version (YouTube changes break old versions)","Check network connectivity and URL validity","Retry the item — the tool supports retry_failed in its options","Capture stderr elsewhere (logs) to see the real cause when the tail is empty"],"exampleFix":"// before\nrun(opts, progress).await?; // fails with generic message\n// after\nmatch run(opts, progress).await {\n    Err(e) if e.to_string().contains(\"o yt-dlp saiu com erro\") => {\n        eprintln!(\"yt-dlp failed; update yt-dlp and retry\");\n    }\n    other => other?,\n}","handlingStrategy":"retry","validationCode":"// pre-check: keep yt-dlp updated\nlet ver = crate::core::ytdlp::ytdlp_command(\"yt-dlp\").arg(\"--version\").output().await?;","typeGuard":null,"tryCatchPattern":"match run(opts, progress).await {\n    Err(e) if e.to_string().contains(\"o yt-dlp saiu com erro\") => {\n        // retry with retry_failed or after updating yt-dlp\n    }\n    other => other?,\n}","preventionTips":["Update yt-dlp regularly (YouTube breakage)","Enable retry_failed in options for flaky networks","Log full stderr to diagnose when the tail is empty"],"tags":["rust","process-exit","yt-dlp","download"],"backgroundTag":"http-request-failed","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"}