{"record":{"id":"0d2b08450b5b84e5","repo":"GitoxideLabs/gitoxide","slug":"peeked-value-exists","errorCode":null,"errorMessage":"peeked value exists","messagePattern":"peeked value exists","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"gix-ref/src/store/file/overlay_iter.rs","lineNumber":161,"sourceCode":"                    (Some(r_gitdir @ Ok((_, git_dir_name))), Some(r_cd @ Ok((_, common_dir_name)))) => {\n                        match git_dir_name.cmp(common_dir_name) {\n                            Ordering::Less => Some((r_gitdir, IterKind::Git)),\n                            Ordering::Equal => Some((r_gitdir, IterKind::GitAndConsumeCommon)),\n                            Ordering::Greater => Some((r_cd, IterKind::Common)),\n                        }\n                    }\n                },\n                None => git_dir.peek().map(|r| (r, IterKind::Git)),\n            }\n        }\n        match self.iter_packed.as_mut() {\n            Some(packed_iter) => match (\n                peek_loose(&mut self.iter_git_dir, self.iter_common_dir.as_mut()),\n                packed_iter.peek(),\n            ) {\n                (None, None) => None,\n                (None, Some(_)) | (Some(_), Some(Err(_))) => {\n                    let res = packed_iter.next().expect(\"peeked value exists\");\n                    Some(self.convert_packed(res))\n                }\n                (Some((_, kind)), None) | (Some((Err(_), kind)), Some(_)) => {\n                    let res = self.loose_iter(kind).next().expect(\"prior peek\");\n                    Some(self.convert_loose(res))\n                }\n                (Some((Ok((_, loose_name)), kind)), Some(Ok(packed))) => match loose_name.as_ref().cmp(packed.name) {\n                    Ordering::Less => {\n                        let res = self.loose_iter(kind).next().expect(\"prior peek\");\n                        Some(self.convert_loose(res))\n                    }\n                    Ordering::Equal => {\n                        drop(packed_iter.next());\n                        let res = self.loose_iter(kind).next().expect(\"prior peek\");\n                        Some(self.convert_loose(res))\n                    }\n                    Ordering::Greater => {\n                        let res = packed_iter.next().expect(\"name retrieval configured\");","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-ref/src/store/file/overlay_iter.rs#L143-L179","documentation":"In `OverlayIter::next`, the packed iterator was `peek`ed and returned `Some`, so the following `next()` must also return `Some`; `expect(\"peeked value exists\")` enforces that. A panic indicates the underlying packed-refs iterator misbehaved (peek and next disagree) or the iterator was mutated concurrently.","triggerScenarios":"Iterating references over a repository with a `packed-refs` file where `Peekable::peek` succeeded but the subsequent `next()` returned `None` — only possible with a broken/concurrently-modified iterator implementation.","commonSituations":"Effectively unreachable; if observed, suspect concurrent modification of the iterator, custom unsafe wrapper code, or a gix-ref/packed-refs bug. Normal single-threaded iteration of `store.iter()` never triggers it.","solutions":["Ensure the iterator is not shared or mutated across threads (wrap in a Mutex if needed)","Re-run the iteration from a fresh `store.iter()`; a transient state may explain it","Verify `packed-refs` integrity and regenerate it (e.g. `git pack-refs --all`)","If reproducible on a fresh iterator, report a gix-ref bug with the packed-refs contents"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Wrap iteration in retry against a fresh iterator\nfor _ in 0..3 { if let Ok(refs) = std::panic::catch_unwind(|| store.iter().collect::<Vec<_>>()) { break; } }","preventionTips":["Never share or mutate iterators across threads","Iterate over a snapshot: collect refs once, then process","Avoid concurrent `git pack-refs` during reads","Regenerate packed-refs if it looks inconsistent"],"tags":["rust","panic","gix-ref","packed-refs","iterator"],"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"}