{"record":{"id":"14b7707c34eab7c8","repo":"jdx/mise","slug":"is-not-a-tar-archive","errorCode":null,"errorMessage":"{} is not a tar archive","messagePattern":"(.+?) is not a tar archive","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/file.rs","lineNumber":2196,"sourceCode":"    let f = File::open(archive)?;\n    Ok(match format {\n        // TODO: we probably shouldn't assume raw is tar.gz, but this was to retain existing behavior\n        ExtractionFormat::TarGz | ExtractionFormat::Raw => Box::new(GzDecoder::new(f)),\n        ExtractionFormat::TarXz => Box::new(xz2::read::XzDecoder::new(f)),\n        ExtractionFormat::TarBz2 => Box::new(BzDecoder::new(f)),\n        ExtractionFormat::TarZst => Box::new(zstd::stream::read::Decoder::new(f)?),\n        ExtractionFormat::Tar => Box::new(f),\n        ExtractionFormat::TarBr | ExtractionFormat::TarLz4 | ExtractionFormat::TarSz => {\n            bail!(\"{format} format not supported\")\n        }\n        ExtractionFormat::Gz\n        | ExtractionFormat::Xz\n        | ExtractionFormat::Bz2\n        | ExtractionFormat::Zst\n        | ExtractionFormat::Br\n        | ExtractionFormat::Lz4\n        | ExtractionFormat::Sz => {\n            bail!(\"{} is not a tar archive\", format)\n        }\n        ExtractionFormat::Zip => bail!(\"zip format not supported\"),\n        ExtractionFormat::SevenZip => bail!(\"7z format not supported\"),\n        ExtractionFormat::Rar => bail!(\"rar format not supported\"),\n    })\n}\n\nfn reset_dir_mtime_to_now(dir: &Path) -> Result<()> {\n    let now = FileTime::now();\n    for entry in WalkDir::new(dir) {\n        let entry = entry?;\n        if entry.file_type().is_file() {\n            set_file_times(entry.path(), now, now)?;\n        }\n    }\n    Ok(())\n}\n","sourceCodeStart":2178,"sourceCodeEnd":2214,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/file.rs#L2178-L2214","documentation":"open_tar rejects non-tar formats with \"{} is not a tar archive\". Single-file compressed formats (gz/xz/bz2/zst/br/lz4/sz), zip, 7z, and rar must never reach the tar reader; this guard fires when a non-tar format leaks into the tar open path.","triggerScenarios":"Calling untar/open_tar with ExtractionFormat::Gz/Xz/Bz2/Zst/Br/Lz4/Sz (this arm) — e.g. a single compressed binary misrouted into the tar extraction path.","commonSituations":"Format detection returned a compression format because the asset is a lone compressed file, but the caller assumed an archive and called untar; dispatch logic bypassed extract_archive.","solutions":["Route compressed single files to decompress_file via the is_compressed_file() check","Use extract_archive so zip/7z/rar are dispatched to the right handlers","Verify the asset actually contains a tar stream (file tool / magic bytes) before tar extraction","Fix the filename-to-format detection if the asset truly is a tarball but got misclassified"],"exampleFix":"// before\nuntar(&archive, &dest, fmt, &opts)?; // fmt == Gz\n// after\nif fmt.is_compressed_file() {\n    decompress_file(&archive, &dest.join(\"binary\"), fmt)?;\n} else {\n    untar(&archive, &dest, fmt, &opts)?;\n}","handlingStrategy":"validation","validationCode":"if fmt.is_compressed_file() {\n    return Err(anyhow!(\"{fmt} is a single-file compression, use decompress_file\"));\n}\nuntar(&archive, &dest, fmt, &opts)?;","typeGuard":"fn is_tar_or_raw(f: ExtractionFormat) -> bool {\n    f.is_tar_archive() || f == ExtractionFormat::Raw\n}","tryCatchPattern":"match untar(&archive, &dest, fmt, &opts) {\n    Err(e) if e.to_string().contains(\"is not a tar archive\") => {\n        decompress_file(&archive, &dest.join(\"binary\"), fmt)?;\n    }\n    other => other?,\n}","preventionTips":["Check is_tar_archive() before any tar extraction","Send compressed single files to decompress_file","Inspect magic bytes (file/xxd) when asset naming is unreliable","Route zip/7z/rar through extract_archive's dispatch table"],"tags":["archive","tar","format-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}