{"record":{"id":"af8c68f0fca93ea1","repo":"GitoxideLabs/gitoxide","slug":"bug-expected-peeled-reference-target-but-found-sy","errorCode":null,"errorMessage":"BUG: expected peeled reference target but found symbolic one","messagePattern":"BUG: expected peeled reference target but found symbolic one","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-ref/src/target.rs","lineNumber":84,"sourceCode":"\n    /// Interpret this target as object id which maybe `None` if it is symbolic.\n    pub fn try_id(&self) -> Option<&oid> {\n        match self {\n            Target::Symbolic(_) => None,\n            Target::Object(oid) => Some(oid),\n        }\n    }\n    /// Interpret this target as object id or panic if it is symbolic.\n    pub fn id(&self) -> &oid {\n        match self {\n            Target::Symbolic(_) => panic!(\"BUG: tries to obtain object id from symbolic target\"),\n            Target::Object(oid) => oid,\n        }\n    }\n    /// Return the contained object id or panic\n    pub fn into_id(self) -> ObjectId {\n        match self {\n            Target::Symbolic(_) => panic!(\"BUG: expected peeled reference target but found symbolic one\"),\n            Target::Object(oid) => oid,\n        }\n    }\n\n    /// Return the contained object id if the target is peeled or itself if it is not.\n    pub fn try_into_id(self) -> Result<ObjectId, Self> {\n        match self {\n            Target::Symbolic(_) => Err(self),\n            Target::Object(oid) => Ok(oid),\n        }\n    }\n    /// Interpret this target as name of the reference it points to which maybe `None` if it an object id.\n    pub fn try_name(&self) -> Option<&FullNameRef> {\n        match self {\n            Target::Symbolic(name) => Some(name.as_ref()),\n            Target::Object(_) => None,\n        }\n    }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-ref/src/target.rs#L66-L102","documentation":"`gix_ref::Target::into_id()` consumes the target and returns the owned object id, panicking with 'BUG: expected peeled reference target but found symbolic one' if the target is `Target::Symbolic`. Same contract as `.id()` but for owned consumption; symbolic targets simply have no id to give.","triggerScenarios":"Calling `target.into_id()` on a `Target::Symbolic(name)`, e.g. converting HEAD's raw target into an `ObjectId` without first resolving the ref chain.","commonSituations":"Refactorings from `.id().to_owned()` to `into_id()` that dropped an existing peel step; code paths that assumed pre-peeled input from callers; processing ref transaction logs containing symbolic entries.","solutions":["Use `try_into_id()` which returns `Err(Self)` for symbolic targets and handle it","Resolve symbolic refs to their final object id before calling `into_id()`","Match on the target and convert each variant appropriately","Add a debug_assert or type-level separation ensuring only peeled targets reach this call"],"exampleFix":"// before\nlet oid = target.into_id(); // panics if symbolic\n// after\nlet oid = target.try_into_id().map_err(|_| anyhow::anyhow!(\"target was symbolic\"))?;","handlingStrategy":"type-guard","validationCode":"let oid = match target {\n    gix_ref::Target::Object(oid) => oid,\n    t @ gix_ref::Target::Symbolic(_) => return Err(anyhow::anyhow!(\"symbolic: {:?}\", t)),\n};","typeGuard":"fn try_owned_id(target: gix_ref::Target) -> Result<gix_hash::ObjectId, gix_ref::Target> {\n    target.try_into_id()\n}","tryCatchPattern":null,"preventionTips":["Use try_into_id() instead of into_id() unless the target is provably peeled","Resolve HEAD and other symbolic refs before consuming them","Add assertions at boundaries where peeled targets are an invariant"],"tags":["rust","panic","refs","symbolic-ref"],"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"}