{"record":{"id":"7bd87f220d4292a4","repo":"GitoxideLabs/gitoxide","slug":"valid-enrich-ref","errorCode":null,"errorMessage":"valid enrich ref","messagePattern":"valid enrich ref","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/command/enrich.rs","lineNumber":52,"sourceCode":"    /// Clear the enrichment instead of setting it.\n    #[arg(long)]\n    clear: bool,\n    #[command(flatten)]\n    target: Target,\n}\n\n#[derive(Debug, clap::Args)]\npub(super) struct Target {\n    /// Commit whose enrichment should be changed.\n    #[arg(default_value = \"HEAD\", value_name = \"REVSPEC\")]\n    revision: OsString,\n}\n\npub(super) fn run(repository: gix::Repository, command: Command) -> Result<()> {\n    match command {\n        Command::Commit(Commit::Todo(args)) => {\n            let target = resolve(&repository, &args.target)?;\n            let reference = crate::enrich::REF_NAME.try_into().expect(\"valid enrich ref\");\n            let (enrichment, changes) = tracked_ref_update(&repository, reference, |repository| {\n                crate::enrich::ensure_todo(repository, target, !args.clear)\n            })?;\n            super::record_undo(\n                &repository,\n                if enrichment.todo {\n                    \"mark commit todo\"\n                } else {\n                    \"clear commit todo\"\n                },\n                changes,\n            );\n            feedback(\n                &repository,\n                target,\n                if enrichment.todo {\n                    \"marked commit todo\"\n                } else {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/command/enrich.rs#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect `crate::enrich::REF_NAME` and make it a valid fully-qualified ref name such as `refs/tix/enrichment`.","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.","If the panic reproduces with a stock build, file a bug — otherwise it is only reachable in modified source."],"exampleFix":"// before\npub const REF_NAME: &str = \"tix/enrichment\"; // invalid: not fully qualified\nlet reference = crate::enrich::REF_NAME.try_into().expect(\"valid enrich ref\");\n// after\npub const REF_NAME: &str = \"refs/tix/enrichment\";\nlet reference = crate::enrich::REF_NAME\n    .try_into()\n    .expect(\"valid enrich ref\");","handlingStrategy":"validation","validationCode":"fn assert_valid_ref(name: &str) {\n    gix::refs::FullNameRef::try_from(name)\n        .unwrap_or_else(|e| panic!(\"static ref {name} is invalid: {e}\"));\n}\n// in tests: assert_valid_ref(crate::enrich::REF_NAME);","typeGuard":"fn is_valid_ref_name(name: &str) -> bool {\n    gix::refs::FullName::try_from(name).is_ok()\n}","tryCatchPattern":"let reference = gix::refs::FullName::try_from(crate::enrich::REF_NAME)\n    .map_err(|e| anyhow::anyhow!(\"configured enrich ref invalid: {e}\"))?;","preventionTips":["Keep static ref names fully qualified under refs/ and free of illegal characters (space, .., ~, ^, :, lock suffix)","Add a compile-time or unit-test check that REF_NAME and TREE_REF_NAME convert to gix::refs::FullName","Convert the constant once in a helper instead of repeating try_into().expect at each call site"],"tags":["rust","panic","git-ref","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}