{"record":{"id":"d638d61b42a3d104","repo":"jdx/mise","slug":"untar-only-supports-tar-formats-got","errorCode":null,"errorMessage":"untar only supports tar formats, got {}","messagePattern":"untar only supports tar formats, got (.+?)","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/file.rs","lineNumber":1948,"sourceCode":"        | ExtractionFormat::Bz2\n        | ExtractionFormat::Zst\n        | ExtractionFormat::Br\n        | ExtractionFormat::Lz4\n        | ExtractionFormat::Sz => {\n            bail!(\"extract_archive does not support compressed single-file format: {format}\")\n        }\n        ExtractionFormat::Rar => bail!(\"rar format not supported\"),\n    }\n}\n\npub fn untar(\n    archive: &Path,\n    dest: &Path,\n    format: ExtractionFormat,\n    opts: &ExtractOptions,\n) -> Result<()> {\n    if !format.is_tar_archive() && format != ExtractionFormat::Raw {\n        bail!(\"untar only supports tar formats, got {}\", format);\n    }\n\n    debug!(\"tar -xf {} -C {}\", archive.display(), dest.display());\n    if let Some(pr) = &opts.pr {\n        pr.set_message(format!(\n            \"extract {}\",\n            archive.file_name().unwrap().to_string_lossy()\n        ));\n    }\n\n    let err = || {\n        let archive = display_path(archive);\n        let dest = display_path(dest);\n        format!(\"failed to extract tar: {archive} to {dest}\")\n    };\n\n    run_blocking(|| {\n        let tar = open_tar(format, archive)?;","sourceCodeStart":1930,"sourceCodeEnd":1966,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/file.rs#L1930-L1966","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Call extract_archive instead - it dispatches zip/7z correctly and only forwards tar variants (and Raw) to untar","If calling untar directly, first check format.is_tar_archive() || format == ExtractionFormat::Raw","Note that Raw is assumed to be gzip-compressed tar; pass TarGz explicitly when the codec is known"],"exampleFix":"// before\nfile::untar(&archive, &dest, format, &opts)?; // format == Zip -> bails\n\n// after\nfile::extract_archive(&archive, &dest, format, &opts)?;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_untar_compatible(f: ExtractionFormat) -> bool {\n    f.is_tar_archive() || f == ExtractionFormat::Raw // Raw is treated as tar.gz\n}\n\nassert!(is_untar_compatible(format), \"untar requires a tar variant, got {format}\");\nfile::untar(&archive, &dest, format, &opts)?;","tryCatchPattern":null,"preventionTips":["Prefer extract_archive over calling untar directly - it owns the format dispatch","If calling untar directly, always guard with format.is_tar_archive() || format == Raw first","Remember Raw is assumed to be gzip-compressed tar in open_tar"],"tags":["archive","extraction","tar","rust","mise"],"backgroundTag":"unsupported-archive-format","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}