jdx/mise · error · eyre::Report

untar only supports tar formats, got {}

Error message

untar only supports tar formats, got {}

What it means

untar is the tar-only extraction entry point behind extract_archive; it rejects any format that is not a tar variant or Raw (Raw is treated as tar.gz per the TODO in open_tar). The error fires when a direct caller passes a zip, 7z, single-file-compression, or rar format into untar.

Source

Thrown at src/file.rs:1948

        | ExtractionFormat::Bz2
        | ExtractionFormat::Zst
        | ExtractionFormat::Br
        | ExtractionFormat::Lz4
        | ExtractionFormat::Sz => {
            bail!("extract_archive does not support compressed single-file format: {format}")
        }
        ExtractionFormat::Rar => bail!("rar format not supported"),
    }
}

pub fn untar(
    archive: &Path,
    dest: &Path,
    format: ExtractionFormat,
    opts: &ExtractOptions,
) -> Result<()> {
    if !format.is_tar_archive() && format != ExtractionFormat::Raw {
        bail!("untar only supports tar formats, got {}", format);
    }

    debug!("tar -xf {} -C {}", archive.display(), dest.display());
    if let Some(pr) = &opts.pr {
        pr.set_message(format!(
            "extract {}",
            archive.file_name().unwrap().to_string_lossy()
        ));
    }

    let err = || {
        let archive = display_path(archive);
        let dest = display_path(dest);
        format!("failed to extract tar: {archive} to {dest}")
    };

    run_blocking(|| {
        let tar = open_tar(format, archive)?;

View on GitHub (pinned to 9dcfcaa0dc)

Solutions

  1. Call extract_archive instead - it dispatches zip/7z correctly and only forwards tar variants (and Raw) to untar
  2. If calling untar directly, first check format.is_tar_archive() || format == ExtractionFormat::Raw
  3. Note that Raw is assumed to be gzip-compressed tar; pass TarGz explicitly when the codec is known

Example fix

// before
file::untar(&archive, &dest, format, &opts)?; // format == Zip -> bails

// after
file::extract_archive(&archive, &dest, format, &opts)?;
Defensive patterns

Strategy: type-guard

Type guard

fn is_untar_compatible(f: ExtractionFormat) -> bool {
    f.is_tar_archive() || f == ExtractionFormat::Raw // Raw is treated as tar.gz
}

assert!(is_untar_compatible(format), "untar requires a tar variant, got {format}");
file::untar(&archive, &dest, format, &opts)?;

Prevention

When it happens

Trigger: Calling file::untar(archive, dest, format, opts) directly with format = Zip, SevenZip, Gz, Xz, Bz2, Zst, Br, Lz4, Sz, or Rar. extract_archive itself never routes these to untar, so this is direct-API misuse or a hand-rolled dispatch table.

Common situations: Library consumers call untar with a format detected from the final extension (.zip); a custom extractor copies the wrong dispatch branch; code assumes every archive path is tar-based.

Related errors


AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17). Data as JSON: /api/errors/d638d61b42a3d104. Report an issue: GitHub.