gitbutlerapp/gitbutler · error
targetCommitId in project_meta.toml is null
Error message
targetCommitId in project_meta.toml is null
What it means
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.
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).
Example fix
// before (project_meta.toml inside snapshot) targetCommitId = "0000000000000000000000000000000000000000" // after targetCommitId = "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678"
Defensive patterns
Strategy: validation
Validate before calling
let id = gix::ObjectId::from_str(&meta.target_commit_id)?;
if id.is_null() { /* reject before restore */ } Type guard
fn is_valid_commit_id(s: &str) -> bool {
gix::ObjectId::from_str(s).map(|id| !id.is_null()).unwrap_or(false)
} Try / catch
match restore_snapshot(&ctx, id) {
Err(e) if e.to_string().contains("targetCommitId ... is null") => {
// snapshot is unusable; restore manually or from another snapshot
}
other => other?,
} Prevention
- 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
When it happens
Trigger: Restoring an oplog snapshot whose project_meta.toml contains targetCommitId = "0000000000000000000000000000000000000000" (or an equivalent null hex string).
Common situations: 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.
Related errors
- Invalid conflict stage
- snapshot additional ref is not a local branch
- targetRef in project_meta.toml is not a remote-tracking…
- cannot snapshot a null target commit id
- Aborting due to empty branch name
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/23b59ada9497410d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-oplog/src/oplog.rs:106
type Error = anyhow::Error;
fn try_from(meta: SnapshotProjectMeta) -> Result<Self> {
let target_ref = meta
.target_ref
.map(|name| {
let name: gix::refs::FullName = name
.try_into()
.context("invalid targetRef in project_meta.toml")?;
if name.category() != Some(gix::refs::Category::RemoteBranch) {
bail!("targetRef in project_meta.toml is not a remote-tracking branch");
}
Ok(name)
})
.transpose()?;
let target_commit_id = gix::ObjectId::from_str(&meta.target_commit_id)
.context("invalid targetCommitId in project_meta.toml")?;
if target_commit_id.is_null() {
bail!("targetCommitId in project_meta.toml is null");
}
Ok(Self {
target_ref,
target_commit_id: Some(target_commit_id),
push_remote: meta.push_remote,
})
}
}
/// The Oplog allows for crating snapshots of the current state of the project as well as restoring to a previous snapshot.
/// Snapshots include the state of the working directory as well as all additional GitButler state (e.g. virtual branches, conflict state).
/// The data is stored as git trees in the following shape:
///
/// ```text
/// .
/// ├── checkout/ (ad-hoc checkouts only)
/// │ ├── commit
/// │ └── refView on GitHub (pinned to 58e5313667)