{"record":{"id":"d903d83bc1e93409","repo":"jdx/mise","slug":"invalid-recovery-content-file","errorCode":null,"errorMessage":"invalid recovery content file","messagePattern":"invalid recovery content file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/recovery.rs","lineNumber":137,"sourceCode":"}\n\nfn validate_blob_id(hash: &str) -> Result<()> {\n    if hash.len() != 64 || !hash.bytes().all(|b| b.is_ascii_hexdigit()) {\n        bail!(\"invalid recovery content identifier\");\n    }\n    Ok(())\n}\n\npub(super) fn read_blob(state_dir: &Path, blob: &Blob) -> Result<Vec<u8>> {\n    use base64::Engine;\n    validate_blob_id(&blob.sha256)?;\n    let bytes = match &blob.inline {\n        Some(inline) => base64::engine::general_purpose::STANDARD.decode(inline)?,\n        None => {\n            let path = super::journal::blobs_dir_in(state_dir).join(&blob.sha256);\n            let metadata = std::fs::symlink_metadata(&path)?;\n            if !metadata.is_file() || metadata.len() != blob.size {\n                bail!(\"invalid recovery content file\");\n            }\n            std::fs::read(path)?\n        }\n    };\n    if bytes.len() as u64 != blob.size || hex::encode(sha2::Sha256::digest(&bytes)) != blob.sha256 {\n        bail!(\"recovery content failed verification\");\n    }\n    Ok(bytes)\n}\n\nfn validate_snapshot(state_dir: &Path, snapshot: &PathSnapshot) -> Result<()> {\n    match snapshot {\n        PathSnapshot::File { content, .. } => {\n            read_blob(state_dir, content)?;\n        }\n        PathSnapshot::Dir {\n            files, links, dirs, ..\n        } => {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/recovery.rs#L119-L155","documentation":"read_blob loads a blob either from inline base64 content or from the blobs directory on disk, then sanity-checks the file before reading: it must exist as a regular file (symlink_metadata, so a symlink is rejected) and its length must equal blob.size. If the file is missing, a symlink, a directory, or has a different length than recorded, the recovery aborts because the stored content no longer matches the journal's record.","triggerScenarios":"Calling validate_snapshot or restore (via recover_path) where a blob's sha256 field names a file in blobs_dir_in(state_dir) that is absent, has been pruned/GC'd, is a symlink, or whose on-disk length differs from the recorded blob.size.","commonSituations":"Sidecar blobs deleted by an aggressive cleaner before the operation was resolved; manual cleanup of the history/state directory; truncated writes after a crash; blobs moved to another machine with incomplete state_dir sync.","solutions":["Restore the missing or truncated blob file in the state_dir blobs directory (e.g. from backup) and retry","Re-run the checkpoint/snapshot so the blob sidecars are rewritten, then recover again","Use discard (or discard_except) to drop the unrecoverable operation instead of restoring it","Verify the state_dir points at the same history directory that recorded the snapshot"],"exampleFix":"// before\n# blob file missing or a symlink\nrecover_path(path, prior)?; // invalid recovery content file\n// after\nls blobs_dir; sha256sum blobs/<sha256>   # confirm file exists, is a regular file\n# if pruned: re-checkpoint then recover\n# if unrecoverable: discard the operation\ndiscard_op(op_id)?;","handlingStrategy":"validation","validationCode":"use std::fs::symlink_metadata;\nfn blob_file_ok(state_dir: &Path, sha: &str, size: u64) -> bool {\n    let p = super::journal::blobs_dir_in(state_dir).join(sha);\n    symlink_metadata(&p).map_or(false, |m| m.is_file() && m.len() == size)\n}","typeGuard":null,"tryCatchPattern":"match recover_path(dest, prior) {\n    Err(e) if e.to_string().contains(\"invalid recovery content file\") => {\n        eprintln!(\"blob sidecar missing/corrupt; re-checkpoint or restore from backup: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Do not prune the blobs directory while operations are unresolved","Verify sha and file size before attempting recovery","Keep state_dir on the same volume/backups as the workspace"],"tags":["filesystem","blob","corruption"],"backgroundTag":"file-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"}