{"record":{"id":"d567f524b3f6db1e","repo":"gleam-lang/gleam","slug":"should-create-archive","errorCode":null,"errorMessage":"should create archive","messagePattern":"should create archive","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/fs/tests.rs","lineNumber":275,"sourceCode":"\n    assert!(dest.join(\"real.txt\").exists());\n    assert!(!dest.join(\"escape\").exists());\n}\n\n// 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":257,"sourceCodeEnd":288,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/fs/tests.rs#L257-L288","documentation":"In `create_tar_archive_sets_proper_permissions`, the call to the archive-creation helper ends with `.expect(\"should create archive\")`. If building the gzipped tar archive fails (I/O error while writing the in-memory buffer, invalid entry path, etc.), the test panics with this message. Creation is expected to be infallible for the well-formed fixtures used.","triggerScenarios":"The `create_tar_archive` helper returns Err while compressing the OutputFile list — e.g. an entry path rejected by the tar writer, an I/O failure on the underlying Vec<u8> writer (compiler-cli/src/fs/tests.rs:275).","commonSituations":"Modifying the archive function or fixtures (e.g. adding a file with an unsupported path like `..` components or an absolute path) and seeing the panic; generally only encountered when changing the tar code or its inputs.","solutions":["Inspect the Err inside create_tar_archive: print it instead of expecting to see the real cause.","Verify every OutputFile path is a valid relative tar path (no `..`, no leading `/`).","Check that Content bytes/paths in the fixture match what the function supports.","If the function legitimately can fail, change it to return Result and assert on the error message."],"exampleFix":"// before\n.expect(\"should create archive\");\n// after\n.unwrap_or_else(|err| panic!(\"should create archive: {err}\"));","handlingStrategy":"try-catch","validationCode":"// Validate entry paths before archiving\nfor f in files {\n    assert!(!f.path.starts_with('/') && !f.path.components().any(|c| c == \"..\"), \"invalid tar path: {}\", f.path);\n}","typeGuard":null,"tryCatchPattern":"let archive = create_tar_archive(files)\n    .unwrap_or_else(|err| panic!(\"should create archive: {err}\"));","preventionTips":["Inspect the underlying Err rather than hiding it behind a bare expect","Validate all entry paths are relative and free of `..` components before archiving","Keep fixtures aligned with what the archive writer supports","Test create_tar_archive's error paths explicitly in unit tests"],"tags":["rust","tests","tar","archive","panic"],"backgroundTag":"file-write-failed","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"}