{"record":{"id":"34d19cb7fdf921b6","repo":"fish-shell/fish-shell","slug":"content-of-path-is-not-valid-utf-8-e","errorCode":null,"errorMessage":"Content of {path} is not valid UTF-8: {e}","messagePattern":"Content of (.+?) is not valid UTF-8: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fluent/src/lib.rs","lineNumber":75,"sourceCode":"            Cow::Owned(mut language) => {\n                assert!(language.ends_with(suffix));\n                language.truncate(language.len() - suffix.len());\n                Box::leak(Box::new(language))\n            }\n        });\n        FluentLocalizationLanguage(language)\n    }))\n});\n\npub fn get_available_languages() -> &'static HashSet<FluentLocalizationLanguage> {\n    &AVAILABLE_LANGUAGES\n}\n\nfn read_ftl_file(path: &str) -> String {\n    let file = FtlFiles::get(path)\n        .unwrap_or_else(|| panic!(\"Tried to get FTL file {path} which does not exist.\"));\n    String::from_utf8(Vec::from(file.data))\n        .unwrap_or_else(|e| panic!(\"Content of {path} is not valid UTF-8: {e}\"))\n}\n\nfn make_bundle(language: Language<'static>) -> Bundle {\n    let langid: LanguageIdentifier = language\n        .parse()\n        .map_err(|e| format!(\"Failed to parse language identifier {language}: {e}\"))\n        .unwrap();\n    let mut bundle = FluentBundle::new_concurrent(vec![langid]);\n    let file_data = read_ftl_file(&format!(\"{language}.ftl\"));\n    // Error handling could use fluent_ftl_tools::display_parse_errors(), but that would require\n    // making the crate a regular dependency.\n    match FluentResource::try_new(file_data) {\n        Ok(res) => {\n            bundle\n                .add_resource(res)\n                .map_err(|e| {\n                    format!(\n                        \"Failed to add FTL resources to the bundle for language {language}: {e:?}\"","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/fish-shell/fish-shell/blob/edb719d76c8f76633f09dbbccedbda1823a7d9d5/crates/fluent/src/lib.rs#L57-L93","documentation":"After successfully fetching the embedded FTL file, read_ftl_file() converts its bytes to a String with String::from_utf8 and panics if the embedded translation resource for {path} contains bytes that are not valid UTF-8 — the packaged asset is corrupted or mis-encoded.","triggerScenarios":"Thrown at crates/fluent/src/lib.rs:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-save the offending .ftl file as UTF-8 (no BOM issues) and rebuild","Use String::from_utf8_lossy to tolerate invalid bytes instead of panicking","Add a build/lint step validating that all embedded FTL assets are valid UTF-8"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"edb719d76c8f76633f09dbbccedbda1823a7d9d5","analyzedAt":"2026-09-03T01:23:54.744Z","contentChangedAt":"2026-09-03T01:23:54.744Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}