jdx/mise · error

no usable preimage

Error message

no usable preimage: {reason}

What it means

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.

Solutions

  1. Choose an earlier or later checkpoint whose snapshot actually recorded this path (`--to <ref>` with a different ref)
  2. Remove manually any post-checkpoint files that have no preimage, since recovery cannot delete them
  3. Re-checkpoint at a point where the path has known-desired content, then roll forward/back between valid checkpoints
  4. Read `reason` in the message — it states exactly why the path was not recorded and may indicate a configurable exclusion

Example fix

// before
rollback(RollbackRequest { paths: vec!["/new-file-after-checkpoint".into()], .. })
// -> no usable preimage: path did not exist at checkpoint
// after
rollback(RollbackRequest { to: Some(later_ref), paths: vec![], all: true, .. })
// or manually: rm /new-file-after-checkpoint
Defensive patterns

Strategy: validation

Validate before calling

// before rolling back, confirm the path is recorded at the target ref
let snap = history::snapshot_for(ref_, &path);
let can_restore = !matches!(snap, PathSnapshot::Unrecorded { .. });
if !can_restore { /* pick another ref or delete the file manually */ }

Type guard

fn is_recorded(s: &PathSnapshot) -> bool {
    !matches!(s, PathSnapshot::Unrecorded { .. })
}

Try / catch

match recover_path(path, prior) {
    Err(e) if e.to_string().starts_with("no usable preimage") => {
        eprintln!("nothing recorded for this path at this ref; pick another ref: {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/9e943e4afd1566cb. Report an issue: GitHub.

Appendix: source

Thrown at src/system/history/recovery.rs:188

                }
            }
            for leaf in files
                .iter()
                .map(|f| &f.rel)
                .chain(links.iter().map(|f| &f.rel))
            {
                if seen
                    .iter()
                    .any(|other| *other != leaf && other.starts_with(leaf))
                {
                    bail!("recovery directory descends through a file or symlink");
                }
            }
            for file in files {
                read_blob(state_dir, &file.content)?;
            }
        }
        PathSnapshot::Unrecorded { reason, .. } => bail!("no usable preimage: {reason}"),
        _ => {}
    }
    Ok(())
}

fn remove_leaf(path: &Path) -> Result<()> {
    match std::fs::symlink_metadata(path) {
        Ok(meta) if meta.is_dir() => std::fs::remove_dir(path)?,
        Ok(_) => std::fs::remove_file(path)?,
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
        Err(error) => return Err(error.into()),
    }
    Ok(())
}

fn set_mode(path: &Path, mode: u32) -> Result<()> {
    #[cfg(unix)]
    {

View on GitHub (pinned to 533346cc37)