{"record":{"id":"eb50891b5e26c446","repo":"LykosAI/StabilityMatrix","slug":"tar-file-not-found","errorCode":null,"errorMessage":"Tar file not found.","messagePattern":"Tar file not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Helper/ArchiveHelper.cs","lineNumber":192,"sourceCode":"    /// First extracts the zipped tar, then extracts the tar and removes the tar.\n    /// </summary>\n    /// <param name=\"archivePath\"></param>\n    /// <param name=\"extractDirectory\"></param>\n    /// <returns></returns>\n    public static async Task<ArchiveInfo> Extract7ZTar(string archivePath, string extractDirectory)\n    {\n        if (!archivePath.EndsWith(\".tar.gz\"))\n        {\n            throw new ArgumentException(\"Archive must be a zipped tar.\");\n        }\n        // Extract the tar.gz to tar\n        await Extract7Z(archivePath, extractDirectory).ConfigureAwait(false);\n\n        // Extract the tar\n        var tarPath = Path.Combine(extractDirectory, Path.GetFileNameWithoutExtension(archivePath));\n        if (!File.Exists(tarPath))\n        {\n            throw new FileNotFoundException(\"Tar file not found.\", tarPath);\n        }\n\n        try\n        {\n            return await Extract7Z(tarPath, extractDirectory).ConfigureAwait(false);\n        }\n        finally\n        {\n            // Remove the tar\n            if (File.Exists(tarPath))\n            {\n                File.Delete(tarPath);\n            }\n        }\n    }\n\n    /// <summary>\n    /// Extracts with auto handling of tar.gz files.","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Helper/ArchiveHelper.cs#L174-L210","documentation":"After the first Extract7Z pass on a .tar.gz, Extract7ZTar expects the inner .tar (archive filename minus .gz) to exist in the extraction directory. If it doesn't, FileNotFoundException('Tar file not found.') is thrown with the expected tar path.","triggerScenarios":"The gz pass ran but produced no tar at the expected path — wrong inner filename, archive extracted into a subdirectory, first-pass extraction failed silently, or the archive was not actually a gzipped tar.","commonSituations":"Archives whose inner file name differs from the outer name (e.g. 'pkg-1.2.tar.gz' containing 'package.tar'); extraction directory pre-populated or cleaned concurrently; corrupted download where 7z extracted nothing.","solutions":["Check the message's tarPath and list the extraction directory to see what the first pass actually produced","Verify the archive is a genuine .tar.gz whose inner name matches the outer base name; if not, extract manually in two explicit steps","Re-download and checksum-verify the archive if the first pass extracted nothing","Use Extract7ZAuto or extract the gz and tar stages separately with explicit paths"],"exampleFix":"// before\nawait ArchiveHelper.Extract7ZTar(archivePath, destDir);\n// after\nvar innerTar = Path.Combine(destDir, Path.GetFileNameWithoutExtension(archivePath));\nif (!File.Exists(innerTar))\n{\n    throw new FileNotFoundException($\"First pass produced no tar; contents: {string.Join(',', Directory.EnumerateFileSystemEntries(destDir))}\", innerTar);\n}","handlingStrategy":"validation","validationCode":"var expectedTar = Path.Combine(destDir, Path.GetFileNameWithoutExtension(archivePath));\nif (!File.Exists(expectedTar))\n    throw new FileNotFoundException($\"Expected inner tar missing: {expectedTar}\", expectedTar);","typeGuard":null,"tryCatchPattern":"try { await ArchiveHelper.Extract7ZTar(archivePath, destDir); }\ncatch (FileNotFoundException ex)\n{\n    logger.LogError(ex, \"Inner tar not produced; inspecting extraction dir\");\n    var contents = Directory.EnumerateFileSystemEntries(destDir);\n    // locate the actual inner tar and extract it manually\n}","preventionTips":["Confirm the archive's inner filename matches the outer base name","List the extraction directory after the gz pass before the tar pass","Checksum-verify the archive before extraction","Clean the destination directory before extraction to avoid stale-path confusion"],"tags":["archive","tar","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}