{"record":{"id":"da86954b6aee25c1","repo":"denoland/deno","slug":"is-not-a-valid-utf-8-file","errorCode":null,"errorMessage":"{} is not a valid UTF-8 file","messagePattern":"(.+?) is not a valid UTF-8 file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/fmt.rs","lineNumber":1669,"sourceCode":"\npub struct FileContents<'a> {\n  pub text: Cow<'a, str>,\n  pub had_bom: bool,\n}\n\nfn read_file_contents(file_path: &Path) -> Result<FileContents<'_>, AnyError> {\n  let file_bytes = fs::read(file_path)\n    .with_context(|| format!(\"Error reading {}\", file_path.display()))?;\n  let had_bom = file_bytes.starts_with(&[0xEF, 0xBB, 0xBF]);\n\n  let charset =\n    deno_media_type::encoding::detect_charset_local_file(&file_bytes);\n  let text = deno_media_type::encoding::decode_owned_source(\n    charset,\n    file_bytes.to_vec(),\n  )\n  .with_context(|| {\n    anyhow!(\"{} is not a valid UTF-8 file\", file_path.display())\n  })?;\n\n  Ok(FileContents {\n    text: Cow::Owned(text),\n    had_bom,\n  })\n}\n\nfn write_file_contents(\n  file_path: &Path,\n  file_contents: &str,\n) -> Result<(), AnyError> {\n  Ok(fs::write(file_path, file_contents)?)\n}\n\npub async fn run_parallelized<F>(\n  file_paths: Vec<PathBuf>,\n  f: F,","sourceCodeStart":1651,"sourceCodeEnd":1687,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/fmt.rs#L1651-L1687","documentation":"Error \"{} is not a valid UTF-8 file\" thrown in denoland/deno.","triggerScenarios":"Thrown at cli/tools/fmt.rs:1669 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}