{"record":{"id":"5213ae4fef43b340","repo":"gleam-lang/gleam","slug":"path-string","errorCode":null,"errorMessage":"path string","messagePattern":"path string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/fs/tests.rs","lineNumber":284,"sourceCode":"        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":266,"sourceCodeEnd":288,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/fs/tests.rs#L266-L288","documentation":"This panic comes from `entry_path.to_str().expect(\"path string\")` in create_tar_archive_sets_proper_permissions. The entry path parsed from the tar header contains bytes that are not valid UTF-8, so Path::to_str returns None and the expect panics. It indicates non-ASCII or raw-byte filenames inside the archive.","triggerScenarios":"An entry in the tar archive created by create_tar_archive has a filename that is not valid UTF-8 (e.g. OS-specific raw bytes from a temp path or non-ASCII filename), so to_str() returns None.","commonSituations":"Running tests on systems whose temp directories contain non-ASCII usernames, or after a change that forwards arbitrary source filenames into archive entry names on Windows (where paths can be WTF-8).","solutions":["Sanitize/normalize entry names before adding them to the archive so they are always ASCII/UTF-8 relative paths.","In the test, use entry.path().to_string_lossy() instead of to_str().expect to tolerate non-UTF-8 names.","If non-UTF-8 names are possible, assert on the raw OsStr or fail with a descriptive message instead of expect.","Ensure temp dirs used by the test (std::env::temp_dir) resolve to ASCII paths, e.g. override TMPDIR in CI."],"exampleFix":"// before\nlet path_str = entry_path.to_str().expect(\"path string\");\n// after\nlet path_str = entry_path.to_string_lossy();","handlingStrategy":"validation","validationCode":"let path_str = entry_path.to_str();\nif path_str.is_none() { eprintln!(\"skipping non-UTF-8 entry: {:?}\", entry_path); }","typeGuard":"fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }","tryCatchPattern":"let path_str = match entry_path.to_str() { Some(s) => s, None => { eprintln!(\"non-UTF-8 path\"); continue; } };","preventionTips":["Normalize filenames to UTF-8 before archiving.","Use to_string_lossy for display/logging paths.","Test archives on systems with non-ASCII temp/user paths."],"tags":["rust","tar","utf-8","test-panic"],"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"}