{"record":{"id":"018ad7cd8e5a905a","repo":"sxyazi/yazi","slug":"e-018ad7","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-vfs/src/stamp.rs","lineNumber":105,"sourceCode":"\t}\n\n\t#[inline]\n\tpub fn sig(&self) -> &str { unsafe { str::from_utf8_unchecked(&self.0[..Self::SIG_LEN]) } }\n\n\t#[inline]\n\tfn name(&self) -> &[u8] { &self.0[Self::SIG_LEN..] }\n}\n\nimpl TryFrom<Vec<u8>> for Stamp {\n\ttype Error = io::Error;\n\n\tfn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {\n\t\tlet (sig, _) = value\n\t\t\t.split_at_checked(Self::SIG_LEN)\n\t\t\t.filter(|(_, n)| !n.is_empty())\n\t\t\t.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, \"Invalid cache stamp\"))?;\n\n\t\tstr::from_utf8(sig).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;\n\t\tOk(Self(value))\n\t}\n}\n","sourceCodeStart":87,"sourceCodeEnd":109,"githubUrl":"https://github.com/sxyazi/yazi/blob/8ebf930f1796ae2076b7d6b0c5e93a1002c18134/yazi-vfs/src/stamp.rs#L87-L109","documentation":"Produced by TryFrom<Vec<u8>> for Stamp when str::from_utf8 fails on the signature portion of the stamp bytes; the Utf8Error's Display becomes the whole message ('{e}', e.g. 'invalid utf-8 sequence of 1 bytes from index 2'). The stamp structure length-checked OK but its signature is not valid UTF-8.","triggerScenarios":"Stamp::try_from(bytes) where the first SIG_LEN bytes contain non-UTF-8 data — a corrupted signature region, or bytes written by a binary format other than the expected textual signature + name layout.","commonSituations":"Bit-rot or partial overwrite corrupting the stamp file; mixing stamp formats across Yazi versions; another application writing into the cache directory.","solutions":["Delete the corrupt stamp file and re-create it via Stamp::write","Clear the cache directory entirely to remove all invalid stamps","Confirm no other process writes to Yazi's cache directory"],"exampleFix":"// before\nlet stamp = Stamp::try_from(bytes)?;\n// after\nlet stamp = Stamp::try_from(bytes).inspect_err(|_| {\n    tracing::warn!(\"dropping corrupt stamp at {}\", stamp_path.display());\n    let _ = std::fs::remove_file(&stamp_path);\n})?;","handlingStrategy":"fallback","validationCode":"let data = tokio::fs::read(&stamp_path).await?;\nif data.len() >= Stamp::SIG_LEN && std::str::from_utf8(&data[..Stamp::SIG_LEN]).is_err() {\n    std::fs::remove_file(&stamp_path).ok(); /* treat as cache miss */\n}","typeGuard":"fn stamp_sig_is_utf8(data: &[u8]) -> bool {\n    data.get(..Stamp::SIG_LEN)\n        .map(|s| std::str::from_utf8(s).is_ok())\n        .unwrap_or(false)\n}","tryCatchPattern":"match Stamp::try_from(data) {\n    Ok(s) => s,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => { purge_stamp(); cache_miss() },\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Keep other applications out of Yazi's cache directory","Regenerate stamps after disk errors or bit-rot","Drop and re-download any stamp that fails UTF-8 validation"],"tags":["utf8","parsing","cache","rust"],"backgroundTag":"invalid-utf8-decode","analyzedSha":"8ebf930f1796ae2076b7d6b0c5e93a1002c18134","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}