{"record":{"id":"3727e2e61eceb6d7","repo":"Tyrrrz/YoutubeDownloader","slug":"entry-clifilename-not-found-in-the-downloaded","errorCode":null,"errorMessage":"Entry '{CliFileName}' not found in the downloaded archive.","messagePattern":"Entry '(.+?)' not found in the downloaded archive\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"YoutubeDownloader.Core/Downloading/FFmpeg.cs","lineNumber":133,"sourceCode":"        IProgress<Percentage>? progress = null,\n        CancellationToken cancellationToken = default\n    )\n    {\n        var archiveFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + \".zip\");\n\n        try\n        {\n            await Http.Client.DownloadAsync(\n                GetDownloadUrl(),\n                archiveFilePath,\n                progress,\n                cancellationToken\n            );\n\n            using var zip = ZipFile.OpenRead(archiveFilePath);\n            var entry =\n                zip.GetEntry(CliFileName)\n                ?? throw new InvalidOperationException(\n                    $\"Entry '{CliFileName}' not found in the downloaded archive.\"\n                );\n\n            entry.ExtractToFile(outputFilePath, true);\n\n            // Make executable on Unix\n            if (!OperatingSystem.IsWindows())\n            {\n                File.SetUnixFileMode(\n                    outputFilePath,\n                    File.GetUnixFileMode(outputFilePath) | UnixFileMode.UserExecute\n                );\n            }\n        }\n        finally\n        {\n            // Clean up the temporary archive\n            if (File.Exists(archiveFilePath))","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/Tyrrrz/YoutubeDownloader/blob/bbcff039515a2ac985e3769f0243a58645a52b28/YoutubeDownloader.Core/Downloading/FFmpeg.cs#L115-L151","documentation":"Thrown inside FFmpeg.DownloadAsync after the FFmpegBin zip is downloaded and opened with ZipFile.OpenRead. The archive is readable, but zip.GetEntry(CliFileName) returns null - there is no root-level entry named exactly 'ffmpeg.exe' (Windows) or 'ffmpeg' (Unix). The library treats the entry name as a packaging contract with the upstream release.","triggerScenarios":"The downloaded zip's layout changed: the binary is nested under a folder (e.g. bin/ffmpeg), renamed, or the platform-specific asset was repackaged. Also reachable if the FFmpeg Version constant (FFmpeg.cs:17, currently \"8.1\") points to a release whose asset for the sys-arch pair follows a different convention, or a transparent proxy/CDN served a small valid zip lacking the entry.","commonSituations":"Tyrrrz/FFmpegBin republished a release with a different layout after a version bump; a corporate proxy substituted/stale-cached the archive; someone edited the Version constant to a tag that doesn't follow the same packaging; a truncated download that ZipFile.OpenRead tolerates but which is missing the entry.","solutions":["Avoid auto-download: install FFmpeg in PATH (or AppContext.BaseDirectory) so TryGetCliFilePath() returns a path and DownloadAsync is never called.","Inspect the failing asset (unzip -l on the URL https://github.com/Tyrrrz/FFmpegBin/releases/download/<Version>/ffmpeg-<sys>-<arch>.zip); if the layout changed, pin Version to a known-good release tag or update the extraction to search Entries.","Manually place the correct FFmpeg binary and pass ffmpegPath explicitly to the downloader."],"exampleFix":"// before: assumes a root-level entry named CliFileName\nvar entry = zip.GetEntry(CliFileName)\n    ?? throw new InvalidOperationException($\"Entry '{CliFileName}' not found in the downloaded archive.\");\n\n// after: tolerate a nested or differently-cased binary\nvar entry = zip.GetEntry(CliFileName)\n    ?? zip.Entries.FirstOrDefault(e => string.Equals(e.Name, CliFileName, StringComparison.Ordinal))\n    ?? throw new InvalidOperationException($\"Entry '{CliFileName}' not found in the downloaded archive.\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await FFmpeg.DownloadAsync(outputPath, progress, ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not found in the downloaded archive\"))\n{\n    // fall back to a system FFmpeg or prompt the user to install one manually\n    var ffmpeg = FFmpeg.TryGetCliFilePath() ?? \"ffmpeg\";\n    // pass ffmpeg explicitly to subsequent DownloadVideoAsync calls\n}","preventionTips":["Prefer a system/provided FFmpeg over auto-download; pre-place it in CI so the download path is never exercised.","Pin the FFmpeg Version constant to a tested FFmpegBin release tag.","After any Version bump, verify the asset zip still contains a root-level CliFileName entry before shipping."],"tags":["ffmpeg","archive","zip","packaging","download","upstream"],"backgroundTag":null,"analyzedSha":"bbcff039515a2ac985e3769f0243a58645a52b28","analyzedAt":"2026-08-13T14:28:37.801Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}