{"record":{"id":"6f97f07504d7c23d","repo":"GitoxideLabs/gitoxide","slug":"valid-tree-enrich-ref","errorCode":null,"errorMessage":"valid tree enrich ref","messagePattern":"valid tree enrich ref","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/command/enrich.rs","lineNumber":79,"sourceCode":"                    \"clear commit todo\"\n                },\n                changes,\n            );\n            feedback(\n                &repository,\n                target,\n                if enrichment.todo {\n                    \"marked commit todo\"\n                } else {\n                    \"cleared commit todo\"\n                },\n            )\n        }\n        Command::Commit(Commit::Note(args)) => edit_note(&repository, &args),\n        Command::Commit(Commit::GitNote(args)) => edit_git_note(&repository, &args),\n        Command::Tree(Tree::ChecksPass(args)) => {\n            let target = resolve(&repository, &args.target)?;\n            let reference = crate::enrich::TREE_REF_NAME.try_into().expect(\"valid tree enrich ref\");\n            let (enrichment, changes) = tracked_ref_update(&repository, reference, |repository| {\n                crate::enrich::ensure_checks_pass(repository, target, !args.clear)\n            })?;\n            super::record_undo(\n                &repository,\n                if enrichment.checks_pass {\n                    \"mark tree checks-pass\"\n                } else {\n                    \"clear tree checks-pass\"\n                },\n                changes,\n            );\n            feedback(\n                &repository,\n                target,\n                if enrichment.checks_pass {\n                    \"marked tree checks-pass\"\n                } else {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/command/enrich.rs#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Correct `crate::enrich::TREE_REF_NAME` to a valid fully-qualified ref name.","Mirror the enrich-ref test: add a test or static assertion that both `REF_NAME` and `TREE_REF_NAME` convert successfully.","Only reachable in modified source; with a stock build, report as a bug."],"exampleFix":"// before\npub const TREE_REF_NAME: &str = \"refs/tix/tree checks-pass\"; // space is illegal\nlet reference = crate::enrich::TREE_REF_NAME.try_into().expect(\"valid tree enrich ref\");\n// after\npub const TREE_REF_NAME: &str = \"refs/tix/tree-checks-pass\";\nlet reference = crate::enrich::TREE_REF_NAME\n    .try_into()\n    .expect(\"valid tree 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::TREE_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::TREE_REF_NAME)\n    .map_err(|e| anyhow::anyhow!(\"configured tree enrich ref invalid: {e}\"))?;","preventionTips":["Validate every static ref-name constant in a unit test alongside REF_NAME","Avoid names with spaces or git-illegal sequences when renaming enrichment refs","Centralize constant conversion in crate::enrich so invalid names fail once, at a single reviewed 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"}