{"record":{"id":"6bc4d6d3c361cdc2","repo":"gitbutlerapp/gitbutler","slug":"commit-is-not-a-snapshot","errorCode":null,"errorMessage":"Commit is not a snapshot","messagePattern":"Commit is not a snapshot","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-oplog/src/oplog.rs","lineNumber":284,"sourceCode":"    ) -> Result<gix::ObjectId> {\n        let PreparedSnapshot {\n            tree_id,\n            target_base_oid,\n        } = prepare_snapshot_with_target(self, perm.read_permission())?;\n        let repo = self.repo.get()?;\n        commit_snapshot(self, &repo, tree_id, details, perm, target_base_oid)\n    }\n\n    #[instrument(skip(self), err(Debug))]\n    fn get_snapshot(&self, sha: gix::ObjectId) -> Result<Snapshot> {\n        let repo = self.repo.get()?;\n        let commit = repo.find_commit(sha)?;\n        let details = commit\n            .message_raw()?\n            .to_str()\n            .ok()\n            .and_then(|msg| SnapshotDetails::from_str(msg).ok())\n            .ok_or(anyhow!(\"Commit is not a snapshot\"))?;\n\n        let snapshot = Snapshot {\n            commit_id: sha,\n            created_at: commit.time()?,\n            details: Some(details),\n        };\n        Ok(snapshot)\n    }\n\n    #[instrument(skip(self), err(Debug))]\n    fn snapshots_iter(\n        &self,\n        oplog_commit_id: Option<gix::ObjectId>,\n        exclude_kind: Vec<OperationKind>,\n        include_kind: Option<Vec<OperationKind>>,\n    ) -> Result<impl Iterator<Item = Result<Snapshot>>> {\n        let repo = self.repo.get()?.clone();\n        let next_commit_id = match oplog_commit_id {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-oplog/src/oplog.rs#L266-L302","documentation":"get_snapshot looks up an oplog snapshot commit by SHA and tries to parse its commit message into a SnapshotDetails struct. If the commit exists but its message is not valid UTF-8 or does not deserialize as snapshot metadata, GitButler concludes the commit is not one of its own oplog snapshots and throws this error. It is a guard against restoring arbitrary non-snapshot commits.","triggerScenarios":"Calling get_snapshot (typically via peel_restore_snapshot) with a SHA that points to a regular Git commit rather than an oplog snapshot commit — e.g. a hand-edited or pruned reflog entry, a snapshot commit whose message was rewritten by rebase/filter-branch, or a corrupted/non-UTF-8 commit message.","commonSituations":"Users who ran `git gc` with reflog expiry, amended or rebased over oplog snapshot commits, or manually passed a wrong commit id to a restore-snapshot code path; also happens after tampering with the internal `gitbutler/oplog` refs.","solutions":["Verify the SHA actually refers to a GitButler oplog snapshot (`git log <sha>`; snapshot commits carry structured SnapshotDetails messages, usually under refs/gitbutler/oplog/*).","List available valid snapshots (`but undo` / oplog list) and use one of those SHAs instead of the arbitrary commit.","If the message was rewritten, the snapshot is unrecoverable via this API; restore manually with git (`git reset --hard <sha>`) acknowledging virtual-branch state may need rebuilding.","If corruption is suspected, re-clone or restore the project from a fresh clone and re-add it in GitButler."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match oplog.get_snapshot(repo, sha) {\n    Ok(snapshot) => snapshot,\n    Err(e) if e.to_string().contains(\"not a snapshot\") => {\n        // fall back to listing valid oplog snapshots\n        oplog.list_snapshots(repo)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never amend, rebase, or filter-branch over commits on refs/gitbutler/oplog/*.","Avoid running reflog expiry (`git reflog expire --expire=now`) that touches oplog refs.","Only pass SHAs obtained from GitButler's snapshot listing APIs to get_snapshot."],"tags":["git","snapshot","oplog","parse-failure"],"backgroundTag":"schema-validation-failed","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}