{"record":{"id":"cbd70a1f38ac7716","repo":"gitbutlerapp/gitbutler","slug":"snapshot-checkout-commit-is-unavailable","errorCode":null,"errorMessage":"snapshot checkout commit {} is unavailable","messagePattern":"snapshot checkout commit (.+?) is unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-oplog/src/oplog.rs","lineNumber":1135,"sourceCode":"            // check for the oid in the repo\n            let commit_oid = gix::ObjectId::from_hex(commit_id)?;\n            if !repo.has_object(commit_oid) {\n                // commit is not in the repo, let's build it from our data\n                let new_commit_oid = deserialize_commit(commit_entry.id())?;\n                if new_commit_oid != commit_oid {\n                    bail!(\"commit id mismatch: failed to recreate a commit from its parts\");\n                }\n            }\n\n            // TODO: in the next iteration, this of course can't be hardcoded.\n            if branch_name == \"workspace\" {\n                restored_workspace_commit = Some(commit_oid);\n            }\n        }\n    }\n    if let Some(checkout) = restored_checkout.as_ref() {\n        if !repo.has_object(checkout.commit_id) {\n            bail!(\n                \"snapshot checkout commit {} is unavailable\",\n                checkout.commit_id\n            );\n        }\n        if checkout.ref_name == workspace_ref\n            && restored_workspace_commit != Some(checkout.commit_id)\n        {\n            bail!(\"snapshot checkout and workspace commits disagree\");\n        }\n    }\n    // Managed snapshots already identify their checkout through the workspace commit entry.\n    let restored_checkout = restored_checkout.or_else(|| {\n        restored_workspace_commit.map(|commit_id| SnapshotCheckout {\n            ref_name: workspace_ref.to_owned(),\n            commit_id,\n        })\n    });\n","sourceCodeStart":1117,"sourceCodeEnd":1153,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-oplog/src/oplog.rs#L1117-L1153","documentation":"Thrown by `restore_snapshot` after the snapshot's checkout identity has been reconstructed: the `SnapshotCheckout.commit_id` is not present in the repository. Unlike the workspace commits, the checkout commit has no serialized-parts fallback, so if the object is missing (e.g. pruned by gc or absent in a copied repo) the restore cannot proceed.","triggerScenarios":"`restore_snapshot` finds `restored_checkout` and `!repo.has_object(checkout.commit_id)` — the commit referenced by the snapshot's checkout ref blob does not exist locally.","commonSituations":"Running `git gc`/`git prune` with aggressive expiration while snapshots still referenced old commits; restoring snapshots in a fresh clone that lacks historical objects; shallow clones missing the commit.","solutions":["Fetch the missing commit from the remote (`git fetch origin` or `git fetch --unshallow`)","Restore an earlier snapshot entry whose checkout commit still exists","Avoid `git gc --prune=now`/aggressive pruning in GitButler-managed repos; loosen `gc.pruneExpire`","If the commit is unrecoverable, recreate the branch at the closest surviving commit and take a fresh snapshot"],"exampleFix":"// checkout commit abc123 was pruned\n// before: restore fails with 'snapshot checkout commit abc123 is unavailable'\n// after:  git fetch --unshallow origin  # object restored, retry restore","handlingStrategy":"retry","validationCode":"let checkout = gix::ObjectId::from_hex(hex_str)?;\nif !repo.has_object(checkout) {\n    run(\"git fetch --unshallow origin\")?; // pull missing objects before restore\n}","typeGuard":null,"tryCatchPattern":"// catch and attempt to recover the object, then retry once\nif let Err(e) = restore_snapshot(entry) {\n    if e.to_string().contains(\"is unavailable\") {\n        run(\"git fetch origin\")?;\n        restore_snapshot(entry)?;\n    } else { return Err(e); }\n}","preventionTips":["Never unshallow a GitButler-managed repo without a full fetch afterwards","Loosen `gc.pruneExpire` so snapshot-referenced commits survive pruning","Fetch from remotes before restoring old snapshots","Verify `repo.has_object` on snapshot heads in pre-restore checks"],"tags":["git","snapshot","missing-object","garbage-collection"],"backgroundTag":"resource-not-found","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"}