{"record":{"id":"cbf626ae4ab572c1","repo":"gleam-lang/gleam","slug":"entry-path","errorCode":null,"errorMessage":"entry path","messagePattern":"entry path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/fs/tests.rs","lineNumber":283,"sourceCode":"    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":265,"sourceCodeEnd":288,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/fs/tests.rs#L265-L288","documentation":"This panic comes from `entry.path().expect(\"entry path\")` while iterating tar archive entries in create_tar_archive_sets_proper_permissions. tar::Archive::entry_path (via entry.path()) errors when the entry path cannot be parsed (e.g. invalid UTF-8/binary path bytes or a malformed long-name header). The expect turns that error into a panic in the test.","triggerScenarios":"The tar archive produced by create_tar_archive contains an entry whose path name is invalid (non-UTF-8 bytes or a corrupt long-name header), so entry.path() returns Err while the test iterates entries.","commonSituations":"A change in the fs module starts embedding unusual filenames, or the tar/gzip round-trip corrupts headers; also happens when cross-platform path handling (Windows separators, unicode) changes.","solutions":["Check the entry names written by create_tar_archive and ensure they are valid, plain UTF-8 relative paths.","Make the test skip entries with unparseable paths instead of panicking: match on entry.path() and continue with a clear failure message.","Verify the tar Builder writes proper long-name (PAX/GNU) headers for long paths.","Update/align the tar crate versions between writer and reader to avoid header parsing incompatibilities."],"exampleFix":"// before\nlet entry_path = entry.path().expect(\"entry path\");\n// after\nlet entry_path = entry.path().map_err(|e| panic!(\"entry path unreadable: {e}\"))?;\n// or fix the writer to always use clean UTF-8 relative paths","handlingStrategy":"validation","validationCode":"// Validate entry paths before use:\nlet path = entry.path()?;\nlet name = path.to_str().ok_or_else(|| anyhow::anyhow!(\"non-UTF-8 entry path\"))?;","typeGuard":"fn readable_entry_path(entry: &tar::Entry<impl Read>) -> Option<String> { entry.path().ok()?.to_str().map(str::to_string) }","tryCatchPattern":"let entry_path = match entry.path() { Ok(p) => p, Err(e) => panic!(\"corrupt tar entry path: {e}\") };","preventionTips":["Write only clean, relative, UTF-8 path names into archives.","Keep the tar crate version consistent between writer and reader.","Handle long paths with PAX extensions rather than raw name fields."],"tags":["rust","tar","test-panic","path-parsing"],"backgroundTag":"invalid-argument-format","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"}