GitoxideLabs/gitoxide · error

review commit names an invalid review reference

Error message

review commit names an invalid review reference

What it means

When loading a review from commit headers, a header naming an `ONTO`/review reference is validated with `history::review_number(name)`. If the referenced name does not parse as a valid numbered review reference, the review commit is considered malformed and the load fails with this message (a follow-up `.context("review commit names an invalid reference")` wraps the conversion error).

Solutions

  1. Delete/recreate the malformed review commit so fresh, valid metadata is written.
  2. Fix the review reference name in the commit message to match the expected numbered format.
  3. Verify the repository's review refs exist and follow the current naming scheme used by `history::review_number`.
  4. Skip or prune stale review commits imported from older tool versions.

Example fix

// before: trusting a corrupt review header
let review = edit::review::review(repo, commit_id)?; // bails
// after: validate the reference first
let name = extract_onto_name(repo, commit_id)?;
if history::review_number(&name).is_none() {
    recreate_review(repo, commit_id)?; // rewrite valid metadata
}
let review = edit::review::review(repo, commit_id)?;
Defensive patterns

Strategy: validation

Validate before calling

if let Some(name) = extract_onto_name(review_commit)? {
    if history::review_number(&name).is_none() {
        // recreate the review or fix its metadata before loading
    }
}

Type guard

fn has_valid_review_ref(name: &BStr) -> bool {
    history::review_number(name).is_some()
}

Prevention

When it happens

Trigger: Decoding a review commit whose `HEADER` metadata value has an `ONTO` prefix, but the resulting name has no valid review number (`history::review_number(name.as_bstr()).is_none()`) — raised from `review()` and transitively from `deletions`/`finish_with_progress`.

Common situations: Hand-edited or corrupted review commit messages; reviews written by an older/incompatible gix-tix version whose reference naming scheme differs; cherry-picked review commits whose metadata no longer matches existing refs.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/6073b2f50eceba20. Report an issue: GitHub.

Appendix: source

Thrown at gix-tix/src/edit/review.rs:44

pub(crate) enum Finish {
    Complete(Finished),
    Conflict(super::rebase::Conflict),
    SelectReturn { tip: ObjectId },
}

pub(crate) fn reference(commit: &gix::objs::Commit) -> Result<Option<gix::refs::FullName>> {
    commit
        .extra_headers
        .iter()
        .find_map(|(name, value)| {
            (name.as_slice() == HEADER)
                .then(|| value.as_slice().strip_prefix(ONTO))
                .flatten()
        })
        .map(|name| {
            if history::review_number(name.as_bstr()).is_none() {
                anyhow::bail!("review commit names an invalid review reference");
            }
            BString::from(name)
                .try_into()
                .context("review commit names an invalid reference")
        })
        .transpose()
}

pub(crate) fn is_review(commit: &gix::objs::Commit) -> bool {
    reference(commit).ok().flatten().is_some()
}

pub(super) fn return_to(commit: &gix::objs::Commit) -> Result<Option<gix::refs::FullName>> {
    commit
        .extra_headers
        .iter()
        .find(|(name, _)| name.as_slice() == RETURN_TO)
        .map(|(_, value)| {

View on GitHub (pinned to e73179060b)