gleam-lang/gleam · error

entry path

Error message

entry path

What it means

This panic comes from `entry.path().expect("entry path")` while iterating tar archive entries in create_tar_archive_sets_proper_permissions. tar::Archive::entry_path (via entry.path()) errors when the entry path cannot be parsed (e.g. invalid UTF-8/binary path bytes or a malformed long-name header). The expect turns that error into a panic in the test.

Solutions

  1. Check the entry names written by create_tar_archive and ensure they are valid, plain UTF-8 relative paths.
  2. Make the test skip entries with unparseable paths instead of panicking: match on entry.path() and continue with a clear failure message.
  3. Verify the tar Builder writes proper long-name (PAX/GNU) headers for long paths.
  4. Update/align the tar crate versions between writer and reader to avoid header parsing incompatibilities.

Example fix

// before
let entry_path = entry.path().expect("entry path");
// after
let entry_path = entry.path().map_err(|e| panic!("entry path unreadable: {e}"))?;
// or fix the writer to always use clean UTF-8 relative paths
Defensive patterns

Strategy: validation

Validate before calling

// Validate entry paths before use:
let path = entry.path()?;
let name = path.to_str().ok_or_else(|| anyhow::anyhow!("non-UTF-8 entry path"))?;

Type guard

fn readable_entry_path(entry: &tar::Entry<impl Read>) -> Option<String> { entry.path().ok()?.to_str().map(str::to_string) }

Try / catch

let entry_path = match entry.path() { Ok(p) => p, Err(e) => panic!("corrupt tar entry path: {e}") };

Prevention

When it happens

Trigger: The tar archive produced by create_tar_archive contains an entry whose path name is invalid (non-UTF-8 bytes or a corrupt long-name header), so entry.path() returns Err while the test iterates entries.

Common situations: A change in the fs module starts embedding unusual filenames, or the tar/gzip round-trip corrupts headers; also happens when cross-platform path handling (Windows separators, unicode) changes.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14). Data as JSON: /api/errors/cbf626ae4ab572c1. Report an issue: GitHub.

Appendix: source

Thrown at compiler-cli/src/fs/tests.rs:283

    let compressed_archive = create_tar_archive(vec![
        OutputFile {
            content: Content::Text("Hello".into()),
            path: "./wibble.txt".into(),
        },
        OutputFile {
            content: Content::Binary(vec![11, 6, 7]),
            path: "./wobble.bin".into(),
        },
    ])
    .expect("should create archive");

    let decoder = flate2::read::GzDecoder::new(Cursor::new(compressed_archive));
    let mut archive = tar::Archive::new(decoder);

    for entry in archive.entries().expect("archive entries") {
        let entry = entry.expect("archive entry");
        let mode = entry.header().mode().expect("entry mode");
        let entry_path = entry.path().expect("entry path");
        let path_str = entry_path.to_str().expect("path string");
        assert_eq!(mode, 0o600, "entry {path_str} has unexpected mode")
    }
}

View on GitHub (pinned to 15b07c7830)