{"record":{"id":"c0e02479b92a3ace","repo":"jdx/mise","slug":"checkpoint-is-unavailable-cannot-find-the-stat","errorCode":null,"errorMessage":"checkpoint {} is unavailable; cannot find the state before operation {}","messagePattern":"checkpoint (.+?) is unavailable; cannot find the state before operation (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/replay.rs","lineNumber":299,"sourceCode":"    if op.status == OperationStatus::Failed && !op.affected.is_empty() {\n        info!(\n            \"history: operation {} failed midway; reversing the {} path(s) it changed\",\n            operation.id,\n            op.affected.len()\n        );\n    }\n    let Some(before_uuid) = &op.before else {\n        bail!(\n            \"checkpoint {} has no protective checkpoint to undo from\",\n            operation.id\n        );\n    };\n    let Some(before) = entries\n        .iter()\n        .find(|entry| &entry.checkpoint.uuid == before_uuid)\n        .cloned()\n    else {\n        bail!(\n            \"checkpoint {} is unavailable; cannot find the state before operation {}\",\n            before_uuid,\n            operation.id\n        );\n    };\n    if op.affected.is_empty() {\n        info!(\"history: operation {} touched nothing\", operation.id);\n        return Ok(());\n    }\n    let paths: Vec<PathBuf> = op\n        .affected\n        .iter()\n        .map(|path| normalize_target(Path::new(path)))\n        .collect();\n    let message = format!(\n        \"undid {} {} ({})\",\n        op.kind.as_str(),\n        operation.id,","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/replay.rs#L281-L317","documentation":"Undo resolved the protective before-checkpoint UUID but cannot find a matching entry in the current history entries list — the checkpoint referenced by op.before is no longer available (pruned, removed, or the store was rebuilt). Since the restore source is gone, mise bails naming both the missing checkpoint and the operation that referenced it.","triggerScenarios":"Running undo when entries.iter().find(|e| e.checkpoint.uuid == before_uuid) returns None — the before-checkpoint was pruned from history, the store was rebuilt/gc'd, or UUIDs changed after re-import.","commonSituations":"History pruning/gc removed old checkpoints; user moved or recreated the dotfiles git store; syncing history between machines dropped entries.","solutions":["Restore via rollback with explicit paths from an available checkpoint instead of undo","Extend history retention / avoid pruning the protective checkpoints of recent operations","Check `mise bootstrap dotfiles history` for which checkpoints remain and pick an available ref"],"exampleFix":"// before\nmise bootstrap dotfiles undo   # before-checkpoint pruned\n// after\nmise bootstrap dotfiles history            # find available checkpoints\nmise bootstrap dotfiles rollback --to <available-ref> --all","handlingStrategy":"validation","validationCode":"const entries = await listHistory();\nconst op = /* selected operation */;\nif (op?.checkpoint?.operation?.before &&\n    !entries.some(e => e.checkpoint.uuid === op.checkpoint.operation.before)) {\n  throw new Error(`before-checkpoint ${op.checkpoint.operation.before} unavailable`);\n}","typeGuard":"const beforeExists = (before: string | undefined, entries: HistoryEntry[]): before is string =>\n  typeof before === \"string\" && entries.some(e => e.checkpoint.uuid === before);","tryCatchPattern":"try {\n  await undo();\n} catch (e) {\n  if (String(e).includes(\"is unavailable\")) {\n    console.error(\"Protective checkpoint pruned; use rollback with an available ref.\");\n  } else throw e;\n}","preventionTips":["Do not prune checkpoints still referenced by recent operations' before refs","Verify checkpoint availability in the store before issuing undo","Recreate history entries atomically so references never dangle"],"tags":["undo","checkpoint","pruned"],"backgroundTag":"record-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}