{"record":{"id":"9e943e4afd1566cb","repo":"jdx/mise","slug":"no-usable-preimage-reason","errorCode":null,"errorMessage":"no usable preimage: {reason}","messagePattern":"no usable preimage: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/recovery.rs","lineNumber":188,"sourceCode":"                }\n            }\n            for leaf in files\n                .iter()\n                .map(|f| &f.rel)\n                .chain(links.iter().map(|f| &f.rel))\n            {\n                if seen\n                    .iter()\n                    .any(|other| *other != leaf && other.starts_with(leaf))\n                {\n                    bail!(\"recovery directory descends through a file or symlink\");\n                }\n            }\n            for file in files {\n                read_blob(state_dir, &file.content)?;\n            }\n        }\n        PathSnapshot::Unrecorded { reason, .. } => bail!(\"no usable preimage: {reason}\"),\n        _ => {}\n    }\n    Ok(())\n}\n\nfn remove_leaf(path: &Path) -> Result<()> {\n    match std::fs::symlink_metadata(path) {\n        Ok(meta) if meta.is_dir() => std::fs::remove_dir(path)?,\n        Ok(_) => std::fs::remove_file(path)?,\n        Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}\n        Err(error) => return Err(error.into()),\n    }\n    Ok(())\n}\n\nfn set_mode(path: &Path, mode: u32) -> Result<()> {\n    #[cfg(unix)]\n    {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/recovery.rs#L170-L206","documentation":"Snapshots may record that no usable preimage exists: PathSnapshot::Unrecorded carries a reason explaining why the original content was never captured. validate_snapshot surfaces that reason verbatim as `no usable preimage: {reason}` when recovery is attempted for such a path, because there is nothing stored to restore.","triggerScenarios":"recover_path targeting a path whose snapshot entry is PathSnapshot::Unrecorded — e.g. the path did not exist at checkpoint time, was outside the recorded set, was too large, or was excluded by policy — and the user asks to roll it back.","commonSituations":"Attempting `history rollback` on files created after the checkpoint (nothing to restore them from); paths excluded from snapshots due to size/type/ignore rules; rolling back to a ref taken before the path was tracked.","solutions":["Choose an earlier or later checkpoint whose snapshot actually recorded this path (`--to <ref>` with a different ref)","Remove manually any post-checkpoint files that have no preimage, since recovery cannot delete them","Re-checkpoint at a point where the path has known-desired content, then roll forward/back between valid checkpoints","Read `reason` in the message — it states exactly why the path was not recorded and may indicate a configurable exclusion"],"exampleFix":"// before\nrollback(RollbackRequest { paths: vec![\"/new-file-after-checkpoint\".into()], .. })\n// -> no usable preimage: path did not exist at checkpoint\n// after\nrollback(RollbackRequest { to: Some(later_ref), paths: vec![], all: true, .. })\n// or manually: rm /new-file-after-checkpoint","handlingStrategy":"validation","validationCode":"// before rolling back, confirm the path is recorded at the target ref\nlet snap = history::snapshot_for(ref_, &path);\nlet can_restore = !matches!(snap, PathSnapshot::Unrecorded { .. });\nif !can_restore { /* pick another ref or delete the file manually */ }","typeGuard":"fn is_recorded(s: &PathSnapshot) -> bool {\n    !matches!(s, PathSnapshot::Unrecorded { .. })\n}","tryCatchPattern":"match recover_path(path, prior) {\n    Err(e) if e.to_string().starts_with(\"no usable preimage\") => {\n        eprintln!(\"nothing recorded for this path at this ref; pick another ref: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Checkpoint before and after creating new files so a preimage exists for removal","Know which paths your checkpoint policy excludes (size/type/ignore rules)","Use --all only when the checkpoint's coverage is understood"],"tags":["rollback","snapshot","state"],"backgroundTag":"resource-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}