{"record":{"id":"e2d6021e053143d7","repo":"gleam-lang/gleam","slug":"archive-entries","errorCode":null,"errorMessage":"archive entries","messagePattern":"archive entries","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/fs/tests.rs","lineNumber":280,"sourceCode":"// https://github.com/gleam-lang/gleam/issues/5992\n#[test]\nfn 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":262,"sourceCodeEnd":288,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/fs/tests.rs#L262-L288","documentation":"`.expect(\"archive entries\")` wraps `archive.entries()` when reading back the generated tarball with flate2's GzDecoder. It panics if iterating the archive fails — typically because the compressed bytes are corrupt or not a valid gzipped tar, or an entry header cannot be read.","triggerScenarios":"Decoding the produced archive in the test: if `create_tar_archive` produced malformed/corrupt gzip data, or the Cursor contents were truncated/altered, `entries()` returns Err and the expect panics (compiler-cli/src/fs/tests.rs:280).","commonSituations":"Encountered when the archive writer is changed (e.g. wrong compression, writing raw tar without gzip) or when decode setup (decoder/reader wiring) is modified incorrectly.","solutions":["Verify the archive is gzip-compressed: `file archive.tar.gz` / feed bytes to `tar -tzf`.","Confirm GzDecoder is the right reader for what create_tar_archive writes (flate2 GzEncoder output).","Print the underlying error: replace expect with `unwrap_or_else(|e| panic!(\"archive entries: {e}\"))`.","Regenerate/inspect the archive bytes with an external tool to spot corruption."],"exampleFix":"// before\nfor entry in archive.entries().expect(\"archive entries\") {\n// after\nfor entry in archive.entries().unwrap_or_else(|e| panic!(\"archive entries: {e}\")) {","handlingStrategy":"try-catch","validationCode":"// Quick sanity check that the bytes are gzip\nassert_eq!(&compressed_archive[..2], &[0x1f, 0x8b], \"not gzip data\");","typeGuard":null,"tryCatchPattern":"for entry in archive.entries().unwrap_or_else(|e| panic!(\"archive entries: {e}\")) {\n    ...\n}","preventionTips":["Match decoder to encoder (gzip in -> GzDecoder; plain tar -> no decoder)","Inspect produced archives with `tar -tzf` when changing writer code","Verify the compression step is not skipped or double-applied","Include the underlying io::Error in panic messages for faster diagnosis"],"tags":["rust","tests","tar","gzip","panic"],"backgroundTag":"unexpected-response-shape","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"}