gleam-lang/gleam · error

entry mode

Error message

entry mode

What it means

This panic comes from `entry.header().mode().expect("entry mode")` in the test helper that verifies permissions of files produced by create_tar_archive. The tar header has no mode field set (e.g. the entry was created without permissions, or uses a header format like plain ustar lacking a valid mode), so `tar::Header::mode()` returns Err and the expect panics. It means the archive builder did not record a file mode for at least one entry.

Solutions

  1. Inspect compiler-cli/src/fs tar creation code and ensure set_mode(0o600) (or the intended mode) is called on every header before appending the file.
  2. Use a tar header format that supports modes (GNU/ustar) and avoid constructing entries with default blank headers.
  3. If a specific entry legitimately has no mode, replace the expect with entry.header().mode().unwrap_or(0) and assert accordingly, or skip modeless entry types like directories/symlinks.
  4. Pin/upgrade the `tar` crate version consistently with the header format the writer produces.

Example fix

// before
let mode = entry.header().mode().expect("entry mode");
// after
let mode = entry.header().mode().unwrap_or(0); // then assert only for regular files
// or fix the writer: header.set_mode(0o600); builder.append(&header, &data)?;
Defensive patterns

Strategy: validation

Validate before calling

// Before iterating, verify entries have modes:
let mode = entry.header().mode();
if mode.is_err() { eprintln!("entry {} has no mode", entry.path().map(|p| p.display().to_string()).unwrap_or_default()); }

Type guard

fn has_mode(header: &tar::Header) -> bool { header.mode().is_ok() }

Try / catch

// Rust panics cannot be caught normally; avoid expect and match on Result instead:
let mode = match entry.header().mode() { Ok(m) => m, Err(e) => { eprintln!("no mode: {e}"); continue; } };

Prevention

When it happens

Trigger: Running the create_tar_archive_sets_proper_permissions test when an entry written into the tar archive by compiler-cli/src/fs has a header without a mode (mode() returns Err(HeaderNotSupported or similar)), e.g. a future change to the archive writer that omits set_mode.

Common situations: A developer modifies the tar-writing code (drops the set_mode call, switches tar Builder append APIs, or changes header format) so entries lose their 0o600 mode, then runs the test suite.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

fn create_tar_archive_sets_proper_permissions() {
    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)