{"record":{"id":"f095d339ddbb1500","repo":"gleam-lang/gleam","slug":"entry-mode","errorCode":null,"errorMessage":"entry mode","messagePattern":"entry mode","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/fs/tests.rs","lineNumber":282,"sourceCode":"fn create_tar_archive_sets_proper_permissions() {\n    let compressed_archive = create_tar_archive(vec![\n        OutputFile {\n            content: Content::Text(\"Hello\".into()),\n            path: \"./wibble.txt\".into(),\n        },\n        OutputFile {\n            content: Content::Binary(vec![11, 6, 7]),\n            path: \"./wobble.bin\".into(),\n        },\n    ])\n    .expect(\"should create archive\");\n\n    let decoder = flate2::read::GzDecoder::new(Cursor::new(compressed_archive));\n    let mut archive = tar::Archive::new(decoder);\n\n    for entry in archive.entries().expect(\"archive entries\") {\n        let entry = entry.expect(\"archive entry\");\n        let mode = entry.header().mode().expect(\"entry mode\");\n        let entry_path = entry.path().expect(\"entry path\");\n        let path_str = entry_path.to_str().expect(\"path string\");\n        assert_eq!(mode, 0o600, \"entry {path_str} has unexpected mode\")\n    }\n}\n","sourceCodeStart":264,"sourceCodeEnd":288,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/fs/tests.rs#L264-L288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Use a tar header format that supports modes (GNU/ustar) and avoid constructing entries with default blank headers.","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.","Pin/upgrade the `tar` crate version consistently with the header format the writer produces."],"exampleFix":"// before\nlet mode = entry.header().mode().expect(\"entry mode\");\n// after\nlet mode = entry.header().mode().unwrap_or(0); // then assert only for regular files\n// or fix the writer: header.set_mode(0o600); builder.append(&header, &data)?;","handlingStrategy":"validation","validationCode":"// Before iterating, verify entries have modes:\nlet mode = entry.header().mode();\nif mode.is_err() { eprintln!(\"entry {} has no mode\", entry.path().map(|p| p.display().to_string()).unwrap_or_default()); }","typeGuard":"fn has_mode(header: &tar::Header) -> bool { header.mode().is_ok() }","tryCatchPattern":"// Rust panics cannot be caught normally; avoid expect and match on Result instead:\nlet mode = match entry.header().mode() { Ok(m) => m, Err(e) => { eprintln!(\"no mode: {e}\"); continue; } };","preventionTips":["Always call header.set_mode before appending files to a tar archive.","Write unit tests that round-trip every header field the writer sets.","Prefer map_err/continue over expect in test helpers that inspect external formats."],"tags":["rust","tar","test-panic","file-permissions"],"backgroundTag":"missing-required-config-field","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}