{"record":{"id":"61dfc42c1c804d28","repo":"toeverything/AFFiNE","slug":"invaliddata-61dfc4","errorCode":"InvalidData","errorMessage":"path bytes are not valid UTF-8","messagePattern":"path bytes are not valid UTF-8","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/native/src/import/onenote/windows_fs.rs","lineNumber":77,"sourceCode":"\n  fn open_file(&self, path: TypedPath) -> Result<Arc<dyn FileSource>, Error> {\n    let file = File::open(resolve_path(path)?)?;\n    let byte_length = file.metadata()?.len();\n    Ok(Arc::new(CachedFileSource::new(WindowsFileSource { file, byte_length })))\n  }\n}\n\nfn resolve_path(path: TypedPath) -> Result<PathBuf, Error> {\n  let path = if path.is_windows() {\n    path.to_path_buf()\n  } else {\n    path\n      .with_windows_encoding_checked()\n      .map_err(|error| Error::new(std::io::ErrorKind::InvalidInput, error))?\n  };\n  let path = path\n    .to_str()\n    .ok_or_else(|| Error::new(std::io::ErrorKind::InvalidData, \"path bytes are not valid UTF-8\"))?;\n  to_verbatim(PathBuf::from(path))\n}\n\nfn as_typed_path(path: &Path) -> Result<TypedPathBuf, Error> {\n  let path = path\n    .to_str()\n    .ok_or_else(|| Error::new(std::io::ErrorKind::InvalidData, \"path is not valid UTF-8\"))?;\n  Ok(TypedPath::windows(path.as_bytes()).to_path_buf())\n}\n\nfn to_verbatim(path: PathBuf) -> Result<PathBuf, Error> {\n  let path = std::path::absolute(path)?.to_string_lossy().replace('/', \"\\\\\");\n  if path.starts_with(r\"\\\\?\\\") {\n    return Ok(PathBuf::from(path));\n  }\n  let mut verbatim = OsString::new();\n  if let Some(path) = path.strip_prefix(r\"\\\\\") {\n    verbatim.push(r\"\\\\?\\UNC\\\");","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/native/src/import/onenote/windows_fs.rs#L59-L95","documentation":"Raised in `resolve_path` when a TypedPath cannot be represented as valid UTF-8: `path.to_str()` returns None after the Windows-encoding check. OneNote import filesystem operations need a UTF-8 str to build a PathBuf, so paths with invalid or non-UTF-8 encodings are rejected; the faulting input is the supplied TypedPath.","triggerScenarios":"Raised in resolve_path when a Windows file path obtained for OneNote import cannot be converted to a UTF-8 str.","commonSituations":"The OneNote section path contains non-UTF-8 bytes (e.g. legacy encodings). Rename the file or folder to valid UTF-8 characters.","solutions":["Use paths that are valid UTF-8.","Convert the path encoding before import."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}