gitbutlerapp/gitbutler · error

Commit is not a snapshot

Error message

Commit is not a snapshot

What it means

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.

Solutions

  1. Verify the SHA actually refers to a GitButler oplog snapshot (`git log <sha>`; snapshot commits carry structured SnapshotDetails messages, usually under refs/gitbutler/oplog/*).
  2. List available valid snapshots (`but undo` / oplog list) and use one of those SHAs instead of the arbitrary commit.
  3. 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.
  4. If corruption is suspected, re-clone or restore the project from a fresh clone and re-add it in GitButler.
Defensive patterns

Strategy: try-catch

Try / catch

match oplog.get_snapshot(repo, sha) {
    Ok(snapshot) => snapshot,
    Err(e) if e.to_string().contains("not a snapshot") => {
        // fall back to listing valid oplog snapshots
        oplog.list_snapshots(repo)?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/6bc4d6d3c361cdc2. Report an issue: GitHub.

Appendix: source

Thrown at crates/gitbutler-oplog/src/oplog.rs:284

    ) -> Result<gix::ObjectId> {
        let PreparedSnapshot {
            tree_id,
            target_base_oid,
        } = prepare_snapshot_with_target(self, perm.read_permission())?;
        let repo = self.repo.get()?;
        commit_snapshot(self, &repo, tree_id, details, perm, target_base_oid)
    }

    #[instrument(skip(self), err(Debug))]
    fn get_snapshot(&self, sha: gix::ObjectId) -> Result<Snapshot> {
        let repo = self.repo.get()?;
        let commit = repo.find_commit(sha)?;
        let details = commit
            .message_raw()?
            .to_str()
            .ok()
            .and_then(|msg| SnapshotDetails::from_str(msg).ok())
            .ok_or(anyhow!("Commit is not a snapshot"))?;

        let snapshot = Snapshot {
            commit_id: sha,
            created_at: commit.time()?,
            details: Some(details),
        };
        Ok(snapshot)
    }

    #[instrument(skip(self), err(Debug))]
    fn snapshots_iter(
        &self,
        oplog_commit_id: Option<gix::ObjectId>,
        exclude_kind: Vec<OperationKind>,
        include_kind: Option<Vec<OperationKind>>,
    ) -> Result<impl Iterator<Item = Result<Snapshot>>> {
        let repo = self.repo.get()?.clone();
        let next_commit_id = match oplog_commit_id {

View on GitHub (pinned to 58e5313667)