jdx/mise · error

recovery content failed verification

Error message

recovery content failed verification

What it means

After decoding a blob (inline base64 or file), read_blob verifies both the byte length matches blob.size and that the SHA-256 hex digest of the bytes equals blob.sha256. A mismatch means the stored content is corrupt or was tampered with; recovery refuses to write unverified content back to disk.

Solutions

  1. Delete the corrupt blob and re-create the snapshot so it is rewritten, then recover from the new snapshot
  2. Restore the blob file from backup and verify `sha256sum` matches blob.sha256 before retrying
  3. If corruption is systemic, check disk health (SMART) and migrate state_dir to healthy storage
  4. Discard the affected operation with the history discard command if the preimage is not needed

Example fix

// before
# blobs/<sha> hash no longer matches journal
recover_path(path, prior)?; // recovery content failed verification
// after
rm blobs_dir/<bad-sha>
# re-checkpoint to regenerate, or restore from backup:
cp backup/blobs/<sha> blobs_dir/<sha>
sha256sum blobs_dir/<sha>   # must equal blob.sha256
recover_path(path, prior)?;
Defensive patterns

Strategy: validation

Validate before calling

use sha2::{Digest, Sha256};
fn blob_matches(bytes: &[u8], size: u64, sha256: &str) -> bool {
    bytes.len() as u64 == size && hex::encode(Sha256::digest(bytes)) == sha256
}

Try / catch

match recover_path(dest, prior) {
    Err(e) if e.to_string().contains("failed verification") => {
        eprintln!("blob corrupt (hash mismatch); regenerate snapshot or restore backup: {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: validate_snapshot or restore reading a blob whose decoded bytes hash to something other than blob.sha256, or whose length differs from blob.size: bit rot, partial/truncated reads, wrong content stored under the id, or edited inline base64.

Common situations: Disk corruption or failing drive; interrupted writes; a user manually edited or re-encoded a blob file; copying state_dir with a tool that altered files; hash recorded under a different hash algorithm.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

    Ok(())
}

pub(super) fn read_blob(state_dir: &Path, blob: &Blob) -> Result<Vec<u8>> {
    use base64::Engine;
    validate_blob_id(&blob.sha256)?;
    let bytes = match &blob.inline {
        Some(inline) => base64::engine::general_purpose::STANDARD.decode(inline)?,
        None => {
            let path = super::journal::blobs_dir_in(state_dir).join(&blob.sha256);
            let metadata = std::fs::symlink_metadata(&path)?;
            if !metadata.is_file() || metadata.len() != blob.size {
                bail!("invalid recovery content file");
            }
            std::fs::read(path)?
        }
    };
    if bytes.len() as u64 != blob.size || hex::encode(sha2::Sha256::digest(&bytes)) != blob.sha256 {
        bail!("recovery content failed verification");
    }
    Ok(bytes)
}

fn validate_snapshot(state_dir: &Path, snapshot: &PathSnapshot) -> Result<()> {
    match snapshot {
        PathSnapshot::File { content, .. } => {
            read_blob(state_dir, content)?;
        }
        PathSnapshot::Dir {
            files, links, dirs, ..
        } => {
            let mut seen = BTreeSet::new();
            for relative in files
                .iter()
                .map(|f| &f.rel)
                .chain(links.iter().map(|f| &f.rel))
                .chain(dirs.iter().map(|f| &f.rel))

View on GitHub (pinned to 533346cc37)