{"record":{"id":"23b59ada9497410d","repo":"gitbutlerapp/gitbutler","slug":"targetcommitid-in-project-meta-toml-is-null","errorCode":null,"errorMessage":"targetCommitId in project_meta.toml is null","messagePattern":"targetCommitId in project_meta\\.toml is null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-oplog/src/oplog.rs","lineNumber":106,"sourceCode":"    type Error = anyhow::Error;\n\n    fn try_from(meta: SnapshotProjectMeta) -> Result<Self> {\n        let target_ref = meta\n            .target_ref\n            .map(|name| {\n                let name: gix::refs::FullName = name\n                    .try_into()\n                    .context(\"invalid targetRef in project_meta.toml\")?;\n                if name.category() != Some(gix::refs::Category::RemoteBranch) {\n                    bail!(\"targetRef in project_meta.toml is not a remote-tracking branch\");\n                }\n                Ok(name)\n            })\n            .transpose()?;\n        let target_commit_id = gix::ObjectId::from_str(&meta.target_commit_id)\n            .context(\"invalid targetCommitId in project_meta.toml\")?;\n        if target_commit_id.is_null() {\n            bail!(\"targetCommitId in project_meta.toml is null\");\n        }\n        Ok(Self {\n            target_ref,\n            target_commit_id: Some(target_commit_id),\n            push_remote: meta.push_remote,\n        })\n    }\n}\n\n/// The Oplog allows for crating snapshots of the current state of the project as well as restoring to a previous snapshot.\n/// Snapshots include the state of the working directory as well as all additional GitButler state (e.g. virtual branches, conflict state).\n/// The data is stored as git trees in the following shape:\n///\n/// ```text\n/// .\n/// ├── checkout/ (ad-hoc checkouts only)\n/// │   ├── commit\n/// │   └── ref","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-oplog/src/oplog.rs#L88-L124","documentation":"When decoding snapshot project metadata from project_meta.toml, targetCommitId is parsed as an ObjectId and must not be the null (all-zero) SHA. A null commit id means the snapshot recorded no meaningful target commit, so restore would be impossible or destructive; try_from bails with this message.","triggerScenarios":"Restoring an oplog snapshot whose project_meta.toml contains targetCommitId = \"0000000000000000000000000000000000000000\" (or an equivalent null hex string).","commonSituations":"Snapshots taken from a project with an uninitialized/broken target (see error 555's write-side); manually edited or corrupted snapshot metadata; template/default toml values never filled in.","solutions":["Correct targetCommitId in the snapshot's project_meta.toml to a valid non-null commit SHA.","Pick the commit from the target ref history (e.g. tip of refs/remotes/origin/<branch>) and use it in the file.","Restore the snapshot is impossible with null id - fall back to manual workspace reconstruction.","Fix the writer side: never snapshot when target_commit_id is null (guard like error 555)."],"exampleFix":"// before (project_meta.toml inside snapshot)\ntargetCommitId = \"0000000000000000000000000000000000000000\"\n// after\ntargetCommitId = \"a1b2c3d4e5f60718293a4b5c6d7e8f9012345678\"","handlingStrategy":"validation","validationCode":"let id = gix::ObjectId::from_str(&meta.target_commit_id)?;\nif id.is_null() { /* reject before restore */ }","typeGuard":"fn is_valid_commit_id(s: &str) -> bool {\n    gix::ObjectId::from_str(s).map(|id| !id.is_null()).unwrap_or(false)\n}","tryCatchPattern":"match restore_snapshot(&ctx, id) {\n    Err(e) if e.to_string().contains(\"targetCommitId ... is null\") => {\n        // snapshot is unusable; restore manually or from another snapshot\n    }\n    other => other?,\n}","preventionTips":["Guard the snapshot writer against null targets (see SnapshotProjectMeta null check) so bad snapshots are never created","Validate project_meta.toml contents when a project/snapshot is loaded","Regenerate snapshots after repairing a project with a null target commit"],"tags":["git","oplog","snapshot-restore","null-value","validation"],"backgroundTag":"null-argument","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"}