{"record":{"id":"f8e8616635f401fb","repo":"gitbutlerapp/gitbutler","slug":"snapshot-checkout-commit-is-null","errorCode":null,"errorMessage":"snapshot checkout commit is null","messagePattern":"snapshot checkout commit is null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-oplog/src/oplog.rs","lineNumber":597,"sourceCode":"    };\n    let commit_entry = snapshot_tree\n        .lookup_entry_by_path(\"checkout/commit\")?\n        .context(\"snapshot checkout ref has no commit\")?;\n    let ref_blob = repo\n        .find_blob(ref_entry.id())\n        .context(\"failed to read snapshot checkout ref\")?;\n    let ref_name = gix::refs::FullName::try_from(ref_blob.data.as_bstr())\n        .context(\"snapshot checkout ref is invalid\")?;\n    if ref_name.category() != Some(gix::refs::Category::LocalBranch) {\n        bail!(\"snapshot checkout ref is not a local branch\");\n    }\n    let commit_blob = repo\n        .find_blob(commit_entry.id())\n        .context(\"failed to read snapshot checkout commit\")?;\n    let commit_id = gix::ObjectId::from_hex(&commit_blob.data)\n        .context(\"snapshot checkout commit is invalid\")?;\n    if commit_id.is_null() {\n        bail!(\"snapshot checkout commit is null\");\n    }\n    Ok(Some(SnapshotCheckout {\n        ref_name,\n        commit_id,\n    }))\n}\n\nfn snapshot_metadata(\n    snapshot_tree: &gix::Tree<'_>,\n    repo: &gix::Repository,\n) -> Result<(\n    ProjectMeta,\n    VirtualBranches,\n    Option<but_db::BranchOrderSnapshot>,\n)> {\n    let vb_toml_entry = snapshot_tree\n        .lookup_entry_by_path(\"virtual_branches.toml\")?\n        .context(\"failed to get virtual_branches.toml blob\")?;","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-oplog/src/oplog.rs#L579-L615","documentation":"Thrown by `snapshot_checkout` when the commit id read from the snapshot's checkout-commit blob is the all-zero object id. A null commit id cannot refer to any object, so GitButler refuses to build a `SnapshotCheckout` from it. Like the null-ref-target check, this guards against corrupt or malformed snapshot data.","triggerScenarios":"`restore_snapshot` -> `snapshot_checkout` reads a checkout-commit blob containing 40 hex zeros instead of a valid commit sha.","commonSituations":"Interrupted or partially written snapshots; snapshots produced by buggy older GitButler versions; manual edits to oplog blobs; copying `.git` state between machines incompletely.","solutions":["Restore a different snapshot entry from the oplog that has a valid checkout commit id","Inspect the snapshot tree blob (`git ls-tree <snapshot-tree>` / `git cat-file blob`) and verify the commit sha is a real 40-char hex id","If the intended commit exists elsewhere, fix the blob to reference it, or recreate the branch at the desired commit and take a new snapshot","Clear the oplog and start fresh if multiple snapshots are corrupt"],"exampleFix":"// corrupt checkout blob\n// before: commit_id = 0000000000000000000000000000000000000000\n// after:  commit_id = 3f9c2b8a1d0e4f5a6b7c8d9e0f1a2b3c4d5e6f70","handlingStrategy":"validation","validationCode":"fn checkout_commit_blob_is_valid(repo: &gix::Repository, entry: &gix::tree::Entry) -> bool {\n    repo.find_blob(entry.id()).ok()\n        .and_then(|b| gix::ObjectId::from_hex(&b.data).ok())\n        .map(|id| !id.is_null())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify snapshot blobs contain real 40-char hex shas before restoring","Avoid manual edits to `.git/gitbutler/` snapshot data","Complete snapshot operations without interrupting the process","Keep backups of the oplog if you script against it"],"tags":["git","snapshot","null-oid","corruption"],"backgroundTag":"checksum-mismatch","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"}