GitoxideLabs/gitoxide · error

valid enrich ref

Error message

valid enrich ref

What it means

A compile-time-constant conversion `crate::enrich::REF_NAME.try_into().expect("valid enrich ref")` inside the `tix enrich commit todo` handler. `REF_NAME` is a hard-coded static reference name (e.g. `refs/tix/enrichment`) that is validated at runtime when converted into a `gix` reference type; the `expect` asserts it is a valid fully-qualified ref name. It can only panic if the constant is edited to something invalid — a developer-time invariant, not a runtime condition.

Solutions

  1. Inspect `crate::enrich::REF_NAME` and make it a valid fully-qualified ref name such as `refs/tix/enrichment`.
  2. Add a unit test (or `const`-time assertion) validating `REF_NAME.try_into()` at compile/test time so regressions fail CI instead of panicking for users.
  3. If the panic reproduces with a stock build, file a bug — otherwise it is only reachable in modified source.

Example fix

// before
pub const REF_NAME: &str = "tix/enrichment"; // invalid: not fully qualified
let reference = crate::enrich::REF_NAME.try_into().expect("valid enrich ref");
// after
pub const REF_NAME: &str = "refs/tix/enrichment";
let reference = crate::enrich::REF_NAME
    .try_into()
    .expect("valid 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::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::REF_NAME)
    .map_err(|e| anyhow::anyhow!("configured enrich ref invalid: {e}"))?;

Prevention

When it happens

Trigger: Executing any `tix enrich` todo subcommand after someone changed the `REF_NAME` constant to a malformed (non-fully-qualified or illegal) ref string, making `try_into()` fail at runtime.

Common situations: Refactoring the enrich reference name to a new scheme without checking git ref-name rules (e.g. dropping the `refs/` prefix, adding spaces or `..`); copy-pasting a partially-qualified name into the constant.

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/7bd87f220d4292a4. Report an issue: GitHub.

Appendix: source

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

    /// Clear the enrichment instead of setting it.
    #[arg(long)]
    clear: bool,
    #[command(flatten)]
    target: Target,
}

#[derive(Debug, clap::Args)]
pub(super) struct Target {
    /// Commit whose enrichment should be changed.
    #[arg(default_value = "HEAD", value_name = "REVSPEC")]
    revision: OsString,
}

pub(super) fn run(repository: gix::Repository, command: Command) -> Result<()> {
    match command {
        Command::Commit(Commit::Todo(args)) => {
            let target = resolve(&repository, &args.target)?;
            let reference = crate::enrich::REF_NAME.try_into().expect("valid enrich ref");
            let (enrichment, changes) = tracked_ref_update(&repository, reference, |repository| {
                crate::enrich::ensure_todo(repository, target, !args.clear)
            })?;
            super::record_undo(
                &repository,
                if enrichment.todo {
                    "mark commit todo"
                } else {
                    "clear commit todo"
                },
                changes,
            );
            feedback(
                &repository,
                target,
                if enrichment.todo {
                    "marked commit todo"
                } else {

View on GitHub (pinned to e73179060b)