Skip to content

fix(file): support pax sparse tar extraction - #10821

Merged
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:agent/pax-sparse-tar-extraction
Jul 7, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:agent/pax-sparse-tar-extraction

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • detect PAX GNU.sparse.* tar metadata before extracting with the Rust tar crate
  • fall back to system tar for sparse archives while preserving the existing preserve_mtime behavior
  • detect nested GNUSparseFile.* artifacts when tar crate extraction partially fails
  • add targeted coverage for PAX sparse detection, nested sparse artifacts, and sparse tar fallback

Discussion

Root cause

tar crate 0.4.46 does not fully handle PAX GNU sparse archives like the smolvm release tarballs. mise already had a system tar fallback for sparse archives, but it only detected GNU sparse entry types and dest/GNUSparseFile.0, so PAX GNU.sparse.* entries could fail before reaching the fallback path.

Validation

  • cargo +stable fmt --check
  • attempted cargo +stable test sparse -- --nocapture, but the local environment spent a long time compiling dependencies and appeared to hang, so full test/clippy validation is left to CI

This PR description was generated by an AI coding assistant.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of sparse archives, including GNU sparse formats and sparse metadata, to reduce failures and incomplete unpacking.
    • Enhanced detection of sparse-file markers in nested paths and ensured a clean retry when needed.
    • Added a more dependable fallback to system archive extraction when built-in extraction can’t safely unpack sparse content.
  • Tests
    • Added coverage for sparse metadata detection and verified end-to-end fallback behavior with sparse tar archives.

@JamBalaya56562
JamBalaya56562 marked this pull request as ready for review July 7, 2026 05:20
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Refactors untar's GNU sparse-file handling in src/file.rs: adds pre-unpack sparse detection, broadens path-based artifact detection, routes fallback extraction through system tar, and adds unit and integration coverage.

Changes

Sparse Tar Extraction Fallback

Layer / File(s) Summary
Sparse detection and system-tar helpers
src/file.rs
Adds tar_entry_is_sparse, path_has_gnu_sparse_artifact, and extract_with_system_tar helper functions.
untar loop and fallback wiring
src/file.rs
Pre-checks entries for sparseness before unpacking, then clears and recreates the destination before re-extracting with system tar when fallback is triggered.
Unit and integration tests
src/file.rs
Adds tests for sparse metadata detection, nested GNUSparseFile.* path detection, and sparse archive fallback extraction.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Untar
  participant TarEntry
  participant Filesystem
  participant SystemTar

  Untar->>TarEntry: tar_entry_is_sparse check
  TarEntry-->>Untar: sparse detected
  Untar->>Filesystem: unpack_in attempt
  Filesystem-->>Untar: unpack complete
  Untar->>Filesystem: path_has_gnu_sparse_artifact scan
  Filesystem-->>Untar: GNUSparseFile.* found
  Untar->>Filesystem: clear and recreate destination
  Untar->>SystemTar: extract_with_system_tar
  SystemTar-->>Filesystem: extracted files
Loading

Poem

A rabbit hopped through tar and straw,
Saw sparse bits and nodded, “Aha!”
With system tar in tow,
The files came back just so,
And GNUSparse ghosts were gone, ta-da! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: improving sparse tar extraction support for file installs.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes sparse tar extraction failures by detecting PAX GNU.sparse.* extension keys on each archive entry before attempting extraction, falling back to system tar when found. The old code only caught GNU sparse entry types and a post-extraction GNUSparseFile.0 filesystem artifact; the new code intercepts both patterns in-loop and before any bytes are written to disk.

  • tar_entry_is_sparse now inspects PAX extensions in addition to is_gnu_sparse(), and path_has_gnu_sparse_artifact provides a second-line defence by matching GNUSparseFile.* components in the archive path (the actual data-entry path in PAX sparse format), so either check alone is sufficient to trigger the fallback.
  • The system-tar invocation is refactored into extract_with_system_tar, and cleanup (remove_all + create_dir_all) is correctly deferred until after the loop confirms a fallback is needed.
  • Three new tests cover PAX metadata detection, nested-path matching, and an end-to-end fallback with a real sparse archive (Unix-only, gracefully skipped when system tar or --format=posix is unavailable).

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to sparse-tar detection and the fallback path, with no regressions for ordinary archives.

The two detection helpers are logically independent and each individually sufficient to catch the failing case. Cleanup before system-tar retry is correctly placed. For normal (non-sparse) archives the only new work per entry is a header-type check and a quick None return from pax_extensions(), so the hot path overhead is negligible. Previous thread concerns about a post-loop WalkDir on every extraction no longer apply — that scan has been replaced entirely by the in-loop path component check. Tests are well-guarded with early-return sentinels for environments that can't produce the required archive format.

No files require special attention.

Important Files Changed

Filename Overview
src/file.rs Adds PAX GNU sparse detection before extraction and extracts system-tar fallback into a helper; cleanup/fallback ordering is correct and defense-in-depth via path_has_gnu_sparse_artifact is meaningful.

Reviews (2): Last reviewed commit: "fix(file): support pax sparse tar extrac..." | Re-trigger Greptile

Comment thread src/file.rs Resolved
Comment thread src/file.rs Resolved
Comment thread src/file.rs Resolved
@JamBalaya56562
JamBalaya56562 force-pushed the agent/pax-sparse-tar-extraction branch from 9547509 to d4adac1 Compare July 7, 2026 05:29
@JamBalaya56562
JamBalaya56562 marked this pull request as draft July 7, 2026 05:29
@JamBalaya56562
JamBalaya56562 marked this pull request as ready for review July 7, 2026 05:30
@jdx
jdx merged commit b57ec82 into jdx:main Jul 7, 2026
33 checks passed
@JamBalaya56562
JamBalaya56562 deleted the agent/pax-sparse-tar-extraction branch July 7, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants