Skip to content

Fix LayerBuilder crash on Windows: absolute root path in tar headers#3

Merged
alongubkin merged 1 commit into
mainfrom
alon/alien-13-fix-layerbuilder-crash-on-windows-absolute-root-path-in-tar
Apr 7, 2026
Merged

Fix LayerBuilder crash on Windows: absolute root path in tar headers#3
alongubkin merged 1 commit into
mainfrom
alon/alien-13-fix-layerbuilder-crash-on-windows-absolute-root-path-in-tar

Conversation

@alongubkin
Copy link
Copy Markdown
Member

Summary

  • On Windows, Path::is_absolute() requires a drive letter, so Unix-style paths like /app/foo pass through normalize_archive_path unchanged. ensure_parent_dirs_exist then walks ancestors up to /, which the tar crate rejects as non-relative.
  • normalize_archive_path now strips leading / via string check as a fallback for Windows.
  • ensure_parent_dirs_exist skips the root "/" path as a safety net.

Closes ALIEN-13

Test plan

  • All 13 existing layer tests pass
  • Verify OCI image build on Windows with x86_64-pc-windows-gnu target

🤖 Generated with Claude Code

On Windows, Path::is_absolute() requires a drive letter, so Unix-style
paths like "/app/foo" aren't detected as absolute. normalize_archive_path
now strips leading '/' via string check as a fallback, and
ensure_parent_dirs_exist skips the root "/" path as a safety net.

Closes ALIEN-13

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear Bot commented Apr 7, 2026

ALIEN-13 Fix LayerBuilder crash on Windows: absolute root path in tar directory headers

Bug

When building an OCI image on Windows using BuildStrategy::FromScratch, dockdash's LayerBuilder creates a tar layer with a directory entry for / (the root). The tar crate rejects this because tar archive paths must be relative.

Error

CONTAINER_OPERATION_FAILED: Container operation failed
├─▶ GENERIC_ERROR: I/O error: Failed to set path for directory header: /: paths in archives must be relative

Root cause

normalize_archive_path uses Path::is_absolute() to detect absolute paths and strip the leading /. On Windows, is_absolute() requires a drive letter (e.g. C:\), so Unix-style paths like /app/alien-test-server are not detected as absolute. The path passes through unchanged, and ensure_parent_dirs_exist walks ancestors up to /, which the tar crate rejects.

Fix

Two changes in src/layer.rs:

  1. normalize_archive_path: Add a fallback that checks for a leading / in the string representation and strips it, handling Unix-style absolute paths on Windows.
  2. ensure_parent_dirs_exist: Skip paths equal to "/" as a safety net, in addition to the existing empty-string check.

Repro

Build any Rust function on Windows via alien-build with the local platform target (x86_64-pc-windows-gnu). The binary builds successfully but OCI image creation fails when LayerBuilder tries to add a directory header for the root path /.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@alongubkin alongubkin merged commit 987d350 into main Apr 7, 2026
6 checks passed
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.

1 participant