{"record":{"id":"d90a5417e3590961","repo":"GitoxideLabs/gitoxide","slug":"head-is-valid-name","errorCode":null,"errorMessage":"HEAD is valid name","messagePattern":"HEAD is valid name","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gix-ref/src/store/file/find.rs","lineNumber":132,"sourceCode":"                    precomposed_partial_name,\n                    packed,\n                    &mut buf,\n                    consider_pseudo_ref,\n                ) {\n                    Ok(Some(r)) => return Ok(Some(decompose_if(r, precomposed_partial_name.is_some()))),\n                    Ok(None) => {\n                        if consider_pseudo_ref && is_pseudo_ref(partial_name.as_bstr()) {\n                            break 'try_directories;\n                        }\n                        continue;\n                    }\n                    Err(err) => return Err(err),\n                }\n            }\n        }\n        if partial_name.as_bstr() != \"HEAD\" {\n            if let Some(mut precomposed) = precomposed_partial_name_storage {\n                precomposed = precomposed.join(\"HEAD\".into()).expect(\"HEAD is valid name\");\n                precomposed_partial_name_storage = Some(precomposed);\n            }\n            self.find_inner(\n                \"remotes\",\n                partial_name\n                    .to_owned()\n                    .join(\"HEAD\".into())\n                    .expect(\"HEAD is valid name\")\n                    .as_ref(),\n                precomposed_partial_name_storage\n                    .as_ref()\n                    .map(std::convert::AsRef::as_ref),\n                None,\n                &mut buf,\n                true, /* consider-pseudo-ref */\n            )\n            .map(|res| res.map(|r| decompose_if(r, precomposed_partial_name_storage.is_some())))\n        } else {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-ref/src/store/file/find.rs#L114-L150","documentation":"This is a Rust `expect()` panic in `gix_ref::store::file::Store::find_one_with_verified_input` (reached via `try_find`, `try_find_loose`, `try_find_packed`, `find_existing_inner`). When a partial name lookup like `origin` fails, the store retries by appending `HEAD` (i.e. `origin/HEAD`); joining `\"HEAD\"` onto the precomposed partial name uses `Path::join`-like `join(\"HEAD\")` and the `expect(\"HEAD is valid name\")` asserts that this join can never produce an invalid `FullName`. It only panics if the precomposed partial name itself was not a valid partial ref name (violating the function's 'verified input' contract).","triggerScenarios":"Calling `try_find`/`find` on the file ref store with a partial name that passes loose-ref verification but, when suffixed with `/` + `HEAD`, exceeds ref-name rules (e.g. a component containing invalid bytes, or a name already at maximum length).","commonSituations":"Hand-constructed partial names passed to low-level `gix_ref` store APIs; ref names built from user input without going through validation; extremely long branch names near the name-length limit.","solutions":["Validate the partial name with `gix_ref::validate` (or use `PartialNameRef::try_from` / `gix_ref::partial_name` constructors) before passing it to `try_find`.","Normalize user-supplied ref lookups through the public `gix` repository API (`repo.find_reference`), which validates names first.","Trim/limit user input so the name plus `/HEAD` stays within ref-name constraints.","If the panic occurs with ordinary branch names, report it upstream with the exact name; it is an internal invariant violation."],"exampleFix":"// before\nstore.try_find(&mut buf, PartialName::from(user_input))?\n// after\nlet partial = PartialNameRef::try_from(user_input.as_bstr())?; // validates first\nstore.try_find(&mut buf, partial)?","handlingStrategy":"validation","validationCode":"use gix_ref::partial_name::PartialNameRef;\nlet partial = PartialNameRef::try_from(user_input.as_bstr())?; // reject invalid names early","typeGuard":"fn safe_partial(input: &[u8]) -> Option<gix_ref::partial_name::PartialNameRef<'_>> {\n    gix_ref::partial_name::PartialNameRef::try_from(bstr::BStr::new(input)).ok()\n}","tryCatchPattern":null,"preventionTips":["Validate partial names before store lookups","Prefer the high-level gix::Repository::find_reference API","Limit user-supplied ref name length and character set"],"tags":["rust","panic","ref-lookup","name-validation"],"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"}