{"record":{"id":"1efc7ca79bb16bf4","repo":"gleam-lang/gleam","slug":"archive-entry","errorCode":null,"errorMessage":"archive entry","messagePattern":"archive entry","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/fs/tests.rs","lineNumber":281,"sourceCode":"#[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":263,"sourceCodeEnd":288,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/fs/tests.rs#L263-L288","documentation":"`.expect(\"archive entry\")` unwraps each individual entry Result while iterating the decoded tar archive. It panics when a specific entry's header cannot be read from the stream — i.e. the archive is truncated or an entry record is malformed, even though the overall entries() iteration started fine.","triggerScenarios":"Reading entry-by-entry in `create_tar_archive_sets_proper_permissions`: a malformed or truncated entry record in the generated archive makes `entry` an Err and the expect panics (compiler-cli/src/fs/tests.rs:281).","commonSituations":"Happens when the writer produces structurally broken tar records (e.g. entry data length mismatch) or the decode buffer is cut short; usually only seen after changing archive-writing code.","solutions":["Surface the real error: replace expect with a panic that includes the entry error.","Validate the generated archive with `tar -tvzf` to find the malformed entry.","Check that each OutputFile's content length matches what the tar builder was given (header size vs written bytes).","Diff against a known-good archive produced before your change to isolate the regression."],"exampleFix":"// before\nlet entry = entry.expect(\"archive entry\");\n// after\nlet entry = entry.unwrap_or_else(|e| panic!(\"archive entry: {e}\"));","handlingStrategy":"try-catch","validationCode":"// Validate the whole archive once and report per-entry errors\nlet entries: Result<Vec<_>, _> = archive.entries().and_then(|it| it.collect());\nlet entries = entries.unwrap_or_else(|e| panic!(\"bad archive: {e}\"));","typeGuard":null,"tryCatchPattern":"let entry = entry.unwrap_or_else(|e| panic!(\"archive entry: {e}\"));","preventionTips":["Ensure header sizes match written content bytes for every tar entry","Check archives with `tar -tvzf` to detect truncated/malformed records early","Keep entry data-length bookkeeping in one place in the writer","Include entry names in error context when unwrapping entry Results"],"tags":["rust","tests","tar","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"}