{"record":{"id":"4318f0dbc6b047e3","repo":"sxyazi/yazi","slug":"invalid-cache-stamp","errorCode":null,"errorMessage":"Invalid cache stamp","messagePattern":"Invalid cache stamp","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"yazi-vfs/src/stamp.rs","lineNumber":103,"sourceCode":"\t\t}\n\t\tOk(())\n\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\tpub fn 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":85,"sourceCodeEnd":109,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-vfs/src/stamp.rs#L85-L109","documentation":"Produced by TryFrom<Vec<u8>> for Stamp with ErrorKind::InvalidData when a stamp file's bytes cannot be a stamp: the payload is shorter than SIG_LEN (26 bytes) or the filename segment after the signature is empty (split_at_checked + filter(|(_, n)| !n.is_empty())). It surfaces through Stamp::read/read_at wrapped as \"Cannot parse cache stamp: Invalid cache stamp\".","triggerScenarios":"Stamp::read(url) opens an existing stamp file that is empty or truncated — a hard kill mid-write, a disk cleaner truncating files — or a stamp written by an older yazi format with a different SIG_LEN, or a foreign file that landed on the hashed stamp path.","commonSituations":"kill -9 of yazi during a stamp write; tmpreaper/systemd-tmpfiles interfering with files under <tmp>/yazi-<uid>; switching between yazi versions that share the same temp dir with different stamp layouts.","solutions":["Delete the offending stamp file (<tmp>/yazi-<uid>/<kind>_<scheme>_<hash>/%stamp/<urlhash>) so yazi recreates it on the next download","Clear the whole <tmp>/yazi-<uid> tree after upgrading yazi to discard incompatible stamp formats","If it recurs with no upgrade or crash, find what else writes into the temp dir (collision or tampering) and exclude it"],"exampleFix":"// before\nlet stamp = Stamp::read(&url).await?; // InvalidData aborts the lookup\n\n// after\nlet stamp = match Stamp::read(&url).await {\n    Ok(s) => s,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => return refetch(url).await, // corrupt stamp == cache miss\n    Err(e) => return Err(e),\n};","handlingStrategy":"validation","validationCode":"// a well-formed stamp is SIG_LEN (26) signature bytes + a non-empty name\nlet meta = std::fs::metadata(&stamp_path)?;\nif meta.len() < 27 {\n    let _ = std::fs::remove_file(&stamp_path); // corrupt: delete and take the cache-miss path\n}","typeGuard":null,"tryCatchPattern":"let stamp = match Stamp::read(&url).await {\n    Ok(s) => s,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => return refetch(url).await, // corrupt stamp == miss\n    Err(e) => return Err(e),\n};","preventionTips":["Clear yazi's temp dir between version upgrades","Avoid kill -9 during downloads; a truncated stamp write is unparseable","Treat parse failures as cache misses and remove the offending file"],"tags":["cache","corruption","invalid-data","temp-dir"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}