{"record":{"id":"d0261b7132225914","repo":"sxyazi/yazi","slug":"cannot-parse-cache-stamp-e","errorCode":null,"errorMessage":"Cannot parse cache stamp: {e}","messagePattern":"Cannot parse cache stamp: (.+?)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-vfs/src/stamp.rs","lineNumber":28,"sourceCode":"\n\tpub async fn read<U>(url: U) -> io::Result<Self>\n\twhere\n\t\tU: AsUrl,\n\t{\n\t\tlet path =\n\t\t\turl.as_url().stamp_entry().ok_or_else(|| io::Error::other(\"Cannot determine cache stamp\"))?;\n\n\t\tSelf::read_at(&path).await\n\t}\n\n\tasync fn read_at(path: &Path) -> io::Result<Self> {\n\t\tlet data = Local::regular(path)\n\t\t\t.read()\n\t\t\t.await\n\t\t\t.map_err(|e| io::Error::new(e.kind(), format!(\"Cannot read cache stamp: {e}\")))?;\n\n\t\tSelf::try_from(data)\n\t\t\t.map_err(|e| io::Error::new(e.kind(), format!(\"Cannot parse cache stamp: {e}\")))\n\t}\n\n\tpub async fn resolve<U, S>(dir: U, key: S) -> io::Result<UrlBuf>\n\twhere\n\t\tU: AsUrl,\n\t\tS: AsStrand,\n\t{\n\t\tlet dir = dir.as_url();\n\t\tlet key = key.as_strand();\n\n\t\tlet mut path =\n\t\t\tdir.auth().stamp_root().ok_or_else(|| io::Error::other(\"Cannot determine stamp root\"))?;\n\t\tpath.push(key.as_os()?);\n\n\t\tlet stamp = Self::read_at(&path).await?;\n\t\tlet name = StrandCow::with(dir.loc().kind(), stamp.name()).map_err(io::Error::other)?;\n\n\t\tlet url = dir.try_join(name)?;","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/sxyazi/yazi/blob/8ebf930f1796ae2076b7d6b0c5e93a1002c18134/yazi-vfs/src/stamp.rs#L10-L46","documentation":"This io::Error is produced when Stamp::try_from(Vec<u8>) fails to parse the bytes read from the cache stamp file; the inner parse error is embedded as 'Cannot parse cache stamp: {e}'. The stamp data was readable but not a valid stamp structure.","triggerScenarios":"Calling Stamp::read_at (via Stamp::resolve) where the file bytes do not decode into a Stamp: wrong SIG length, empty name portion, or invalid UTF-8 in the signature region.","commonSituations":"A truncated or corrupted stamp file (crash during write, disk full); a different Yazi version changed the stamp format; the cache file was overwritten by another program.","solutions":["Delete the invalid stamp file and re-create it via Stamp::write (re-download the entry)","Clear the Yazi cache directory to remove stale-format stamps","Upgrade/downgrade consistently so the stamp format version matches between writer and reader"],"exampleFix":"// before\nlet url = Stamp::resolve(dir, key).await?;\n// after\nlet url = Stamp::resolve(dir, key).await\n    .inspect_err(|_| let _ = std::fs::remove_file(stamp_path)) // drop corrupt stamp\n    .or_else(|_| re_download().await)?;","handlingStrategy":"fallback","validationCode":"let data = tokio::fs::read(&stamp_path).await?;\nif data.len() <= Stamp::SIG_LEN { /* corrupt: drop and re-fetch */ }","typeGuard":"fn stamp_parseable(data: &[u8]) -> bool {\n    data.get(Stamp::SIG_LEN..).map(|n| !n.is_empty()).unwrap_or(false)\n        && std::str::from_utf8(&data[..Stamp::SIG_LEN]).is_ok()\n}","tryCatchPattern":"match Stamp::resolve(dir, key).await {\n    Ok(url) => url,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => { remove_stamp(&path); cache_miss_fallback() },\n    Err(e) => return Err(e),\n}","preventionTips":["Never hand-edit stamp files; only create them via Stamp::write","Keep the same Yazi version for writer and reader of the cache","Purge the cache after upgrading if the stamp format changed"],"tags":["parsing","cache","serialization","rust"],"backgroundTag":"cache-stamp-parse-failed","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"}