jdx/mise · error
recovery directory descends through a file or symlink
Error message
recovery directory descends through a file or symlink
What it means
After ensuring all individual rel paths are normal and unique, validate_snapshot additionally rejects leaf paths that are a prefix of another recorded path. This means the snapshot claims a directory entry that is itself recorded as a file or symlink — recovery cannot create children under a file/symlink, so the snapshot is structurally inconsistent and is rejected before any writes happen.
Solutions
- Fix the journal so paths are consistent — either drop the descendants under the file/symlink leaf or record the leaf as a directory
- Re-record the snapshot with the tree in a stable state (no concurrent modifications)
- If the tree genuinely changed (file replaced by dir), discard the old snapshot and take a new one
Example fix
// before # journal contains file 'a' AND file 'a/b' -> inconsistent recover_path(path, prior)?; // after # remove or fix one of the conflicting entries, e.g. keep the tree form: # dirs: a/, files: a/b validate/re-record snapshot; recover_path(path, prior)?;
Defensive patterns
Strategy: validation
Validate before calling
fn consistent_prefixes(rels: &[std::path::PathBuf]) -> bool {
!rels.iter().any(|leaf| {
rels.iter().any(|other| *other != *leaf && other.starts_with(leaf))
})
} Prevention
- Build snapshot entries from a single stable directory scan (no concurrent mutation)
- Assert no file/link leaf is also a directory prefix when serializing
- Re-snapshot after any file↔directory conversion instead of merging old journals
When it happens
Trigger: recover_path on a snapshot where e.g. rel `a` is recorded as a file or link while `a/b` is also recorded (as dir or file), so `seen` contains a path that starts_with the leaf path.
Common situations: Corrupted or hand-assembled journals; snapshots recorded while the tree was being modified concurrently (a dir became a file mid-scan); merging snapshots from different runs with overlapping paths.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- a parent directory is now a symlink; left untouched
- app Info.plist must be a regular file
- app target is outside an allowed Applications directory
- artifact directory was initialized
- binary target is not an owned Caskroom symlink
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/e1520cd875764c34.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/history/recovery.rs:181
if relative.as_os_str().is_empty()
|| !relative
.components()
.all(|c| matches!(c, Component::Normal(_)))
|| !seen.insert(relative)
{
bail!("invalid path inside recovery directory");
}
}
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()),View on GitHub (pinned to 533346cc37)