{"record":{"id":"c381e3db38c4b155","repo":"jdx/mise","slug":"the-annotated-commit-is-not-in-the-current-history","errorCode":null,"errorMessage":"the annotated commit is not in the current history","messagePattern":"the annotated commit is not in the current history","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/shadow.rs","lineNumber":1653,"sourceCode":"\n    const ANNOTATION_TRAILER: &'static str = \"Mise-Annotation: \";\n\n    /// An annotation is an empty ordinary child commit, so labels and\n    /// descriptions travel with the same ancestry without rewriting it.\n    pub(crate) fn write_annotation(\n        &self,\n        target: &str,\n        annotation: &super::store::Annotation,\n    ) -> Result<()> {\n        let head = self\n            .ref_oid(Self::HISTORY_REF)?\n            .ok_or_else(|| eyre::eyre!(\"no history to annotate\"))?;\n        if !self\n            .rev_list(&head, usize::MAX)?\n            .iter()\n            .any(|commit| commit == target)\n        {\n            bail!(\"the annotated commit is not in the current history\");\n        }\n        let message = format!(\n            \"annotate dotfile history\\n\\n{}{}\",\n            Self::ANNOTATION_TRAILER,\n            serde_json::to_string(&(target, annotation))?\n        );\n        let commit = self.commit_tree(&self.output_tree_of(&head)?, vec![&head], &message)?;\n        self.update_history_head(&commit, Some(&head))\n    }\n\n    #[cfg(test)]\n    pub(crate) fn read_annotation(\n        &self,\n        commit: &str,\n    ) -> Result<Option<(String, super::store::Annotation)>> {\n        let message = self.output_str(PlumbingCall::new([\"show\", \"-s\", \"--format=%B\", commit]))?;\n        Self::annotation_from_message(&message)\n    }","sourceCodeStart":1635,"sourceCodeEnd":1671,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/shadow.rs#L1635-L1671","documentation":"Before rewriting dotfile history with an annotation commit, mise verifies the target commit is reachable from the current history HEAD via rev-list. If the commit is not an ancestor of the current history, the annotation would be attached to a dangling commit, so mise refuses. This protects the integrity of the shadow dotfile history graph.","triggerScenarios":"Annotating a dotfile history checkpoint whose commit hash is no longer reachable: after history was rewritten/reset, the checkpoint was pruned, or the user supplied a stale commit id from an older history repo.","commonSituations":"History repo re-initialized or reset between creating and annotating a checkpoint; annotating from a different machine's history; referencing an old commit id after a force-rewrite of the shadow history.","solutions":["Run `mise dotfiles history list` (or equivalent) to see currently valid checkpoints.","Annotate an existing reachable checkpoint instead of the stale commit id.","If history was unintentionally rewritten, restore the previous history repo state from backup.","If the commit is genuinely gone, recreate the annotation on a fresh checkpoint."],"exampleFix":"// before: stale commit id\n$ mise dotfiles annotate a1b2c3d \"note\"\nError: the annotated commit is not in the current history\n\n// after: use a current checkpoint\n$ mise dotfiles history list\n$ mise dotfiles annotate <current-checkpoint-id> \"note\"","handlingStrategy":"validation","validationCode":"let reachable = history.rev_list(head, usize::MAX)?.iter().any(|c| c == target);\nif !reachable {\n  eprintln!(\"{target} is not in current history; pick a checkpoint from `history list`\");\n}","typeGuard":"fn is_annotatable(history: &HistoryRepo, target: &str) -> bool {\n  history.rev_list(head(), usize::MAX)\n    .map(|commits| commits.iter().any(|c| c == target))\n    .unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Always annotate ids taken from the current `history list` output.","Avoid caching checkpoint ids across history rewrites or machine switches.","Back up the history repo before any manual reset."],"tags":["git","dotfiles","history","stale-reference"],"backgroundTag":"resource-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"}