jdx/mise · error

invalid recovery content identifier

Error message

invalid recovery content identifier

What it means

validate_blob_id enforces that every recovery blob identifier is exactly 64 lowercase/uppercase ASCII hex characters — a SHA-256 hex digest. Recovery blob filenames are joined directly into the blobs directory path, so an identifier with other characters could traverse directories or reference a corrupt record; anything failing the shape check is rejected before any filesystem access.

Solutions

  1. Fix the sha256 value in the snapshot/journal metadata so it is exactly 64 hex characters
  2. Regenerate the snapshot if the journal metadata is corrupted rather than hand-editing ids
  3. If the id came from upstream input, normalize it (strip prefix, lowercase, re-encode from raw bytes) before storing it in the Blob

Example fix

// before
let blob = Blob { sha256: "sha256:abc123".into(), .. };
// after
let hex = "sha256:abc123".trim_start_matches("sha256:");
assert_eq!(hex.len(), 64);
let blob = Blob { sha256: hex.to_ascii_lowercase(), .. };
Defensive patterns

Strategy: validation

Validate before calling

fn valid_blob_id(s: &str) -> bool {
    s.len() == 64 && s.bytes().all(|b| b.is_ascii_hexdigit())
}

Prevention

When it happens

Trigger: Calling read_blob or discard_except with a Blob whose sha256 field is not 64 hex chars: empty string, truncated digest, base64 instead of hex, a `sha256:<hex>` prefixed string, or an id containing `/`, `..`, or whitespace.

Common situations: Hand-editing or partially copying journal/blob metadata; tooling that stored a digest with a `sha256:` prefix; truncated or corrupted journal entries from a crashed process.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

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

    }
    restore(state_dir, path, prior)
}

fn validate_destination(path: &Path) -> Result<()> {
    if !path.is_absolute() || path.components().any(|c| matches!(c, Component::ParentDir)) {
        bail!("invalid recovery destination");
    }
    for parent in path.ancestors().skip(1) {
        if std::fs::symlink_metadata(parent).is_ok_and(|meta| meta.is_symlink()) {
            bail!("a parent directory is now a symlink; left untouched");
        }
    }
    Ok(())
}

fn validate_blob_id(hash: &str) -> Result<()> {
    if hash.len() != 64 || !hash.bytes().all(|b| b.is_ascii_hexdigit()) {
        bail!("invalid recovery content identifier");
    }
    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)?
        }
    };

View on GitHub (pinned to 533346cc37)