LykosAI/StabilityMatrix · error · ArgumentException

Archive must be a zipped tar.

Error message

Archive must be a zipped tar.

What it means

Extract7ZTar requires the archive path to end with '.tar.gz'. This guard throws ArgumentException before doing any work when the extension doesn't match, because the two-pass extraction (gz then tar) only makes sense for zipped tars.

Solutions

  1. Rename/normalize the archive to a '.tar.gz' extension before calling Extract7ZTar, or map '.tgz' to it
  2. Use Extract7ZAuto instead, which dispatches on the archive type automatically
  3. Check the downloaded file's actual extension/content type before choosing the extraction method

Example fix

// before
await ArchiveHelper.Extract7ZTar(archivePath, destDir); // archivePath = "foo.tgz"
// after
if (archivePath.EndsWith(".tgz"))
    archivePath = Path.ChangeExtension(archivePath, ".tar.gz"); // after renaming on disk
await ArchiveHelper.Extract7ZAuto(archivePath, destDir);
Defensive patterns

Strategy: validation

Validate before calling

if (!archivePath.EndsWith(".tar.gz", StringComparison.OrdinalIgnoreCase))
    throw new ArgumentException($"Extract7ZTar requires .tar.gz, got: {archivePath}");

Type guard

static bool IsZippedTarPath(string p) =>
    p.EndsWith(".tar.gz", StringComparison.OrdinalIgnoreCase);

Try / catch

try { await ArchiveHelper.Extract7ZTar(archivePath, destDir); }
catch (ArgumentException ex)
{
    logger.LogWarning(ex, "Not a .tar.gz; falling back to Extract7ZAuto");
    await ArchiveHelper.Extract7ZAuto(archivePath, destDir);
}

Prevention

When it happens

Trigger: Calling Extract7ZTar with a path not ending in '.tar.gz' — e.g. '.tgz', '.tar.bz2', '.zip', or a URL-derived filename without the extension.

Common situations: Download code saving a '.tgz' file (a valid gzipped tar) but passing it to Extract7ZTar, which only accepts the literal '.tar.gz' suffix; passing extracted-directory filenames stripped of their double extension.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/18c781761f7e91a4. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Core/Helper/ArchiveHelper.cs:183

        }
        catch (Exception e)
        {
            throw new Exception($"Could not parse 7z output [{e.Message}]: {output.ToRepr()}");
        }
    }

    /// <summary>
    /// Extracts a zipped tar (i.e. '.tar.gz') archive.
    /// First extracts the zipped tar, then extracts the tar and removes the tar.
    /// </summary>
    /// <param name="archivePath"></param>
    /// <param name="extractDirectory"></param>
    /// <returns></returns>
    public static async Task<ArchiveInfo> Extract7ZTar(string archivePath, string extractDirectory)
    {
        if (!archivePath.EndsWith(".tar.gz"))
        {
            throw new ArgumentException("Archive must be a zipped tar.");
        }
        // Extract the tar.gz to tar
        await Extract7Z(archivePath, extractDirectory).ConfigureAwait(false);

        // Extract the tar
        var tarPath = Path.Combine(extractDirectory, Path.GetFileNameWithoutExtension(archivePath));
        if (!File.Exists(tarPath))
        {
            throw new FileNotFoundException("Tar file not found.", tarPath);
        }

        try
        {
            return await Extract7Z(tarPath, extractDirectory).ConfigureAwait(false);
        }
        finally
        {
            // Remove the tar

View on GitHub (pinned to af93d6ef57)