GitoxideLabs/gitoxide · error

valid tree enrich ref

Error message

valid tree enrich ref

What it means

Same invariant pattern as the enrich ref: `crate::enrich::TREE_REF_NAME.try_into().expect("valid tree enrich ref")` converts a hard-coded constant reference name (for the checks-pass tree enrichment) into a `gix` reference type in the `tix enrich tree checks-pass` handler. The `expect` documents the assumption that the constant is always a valid ref name; panic means the constant was changed to something git rejects.

Solutions

  1. Correct `crate::enrich::TREE_REF_NAME` to a valid fully-qualified ref name.
  2. Mirror the enrich-ref test: add a test or static assertion that both `REF_NAME` and `TREE_REF_NAME` convert successfully.
  3. Only reachable in modified source; with a stock build, report as a bug.

Example fix

// before
pub const TREE_REF_NAME: &str = "refs/tix/tree checks-pass"; // space is illegal
let reference = crate::enrich::TREE_REF_NAME.try_into().expect("valid tree enrich ref");
// after
pub const TREE_REF_NAME: &str = "refs/tix/tree-checks-pass";
let reference = crate::enrich::TREE_REF_NAME
    .try_into()
    .expect("valid tree enrich ref");
Defensive patterns

Strategy: validation

Validate before calling

fn assert_valid_ref(name: &str) {
    gix::refs::FullNameRef::try_from(name)
        .unwrap_or_else(|e| panic!("static ref {name} is invalid: {e}"));
}
// in tests: assert_valid_ref(crate::enrich::TREE_REF_NAME);

Type guard

fn is_valid_ref_name(name: &str) -> bool {
    gix::refs::FullName::try_from(name).is_ok()
}

Try / catch

let reference = gix::refs::FullName::try_from(crate::enrich::TREE_REF_NAME)
    .map_err(|e| anyhow::anyhow!("configured tree enrich ref invalid: {e}"))?;

Prevention

When it happens

Trigger: Running `tix enrich tree checks-pass` in a build where the `TREE_REF_NAME` constant is not a valid fully-qualified git reference name, so `try_into()` returns `Err` at runtime.

Common situations: Renaming the tree-enrichment ref during refactors and introducing illegal characters, relative names, or case/`--`/lock-suffix violations; forgetting to validate the new constant in tests.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at gix-tix/src/command/enrich.rs:79

                    "clear commit todo"
                },
                changes,
            );
            feedback(
                &repository,
                target,
                if enrichment.todo {
                    "marked commit todo"
                } else {
                    "cleared commit todo"
                },
            )
        }
        Command::Commit(Commit::Note(args)) => edit_note(&repository, &args),
        Command::Commit(Commit::GitNote(args)) => edit_git_note(&repository, &args),
        Command::Tree(Tree::ChecksPass(args)) => {
            let target = resolve(&repository, &args.target)?;
            let reference = crate::enrich::TREE_REF_NAME.try_into().expect("valid tree enrich ref");
            let (enrichment, changes) = tracked_ref_update(&repository, reference, |repository| {
                crate::enrich::ensure_checks_pass(repository, target, !args.clear)
            })?;
            super::record_undo(
                &repository,
                if enrichment.checks_pass {
                    "mark tree checks-pass"
                } else {
                    "clear tree checks-pass"
                },
                changes,
            );
            feedback(
                &repository,
                target,
                if enrichment.checks_pass {
                    "marked tree checks-pass"
                } else {

View on GitHub (pinned to e73179060b)