{"record":{"id":"29f0a8c692547b43","repo":"GitoxideLabs/gitoxide","slug":"this-one-only-happens-on-iteration-creation","errorCode":null,"errorMessage":"this one only happens on iteration creation","messagePattern":"this one only happens on iteration creation","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-ref/src/store/file/overlay_iter.rs","lineNumber":82,"sourceCode":"        }\n    }\n\n    fn convert_packed(\n        &mut self,\n        packed: Result<packed::Reference<'p>, packed::iter::Error>,\n    ) -> Result<Reference, Error> {\n        packed\n            .map(Into::into)\n            .map(|r| self.strip_namespace(r))\n            .map_err(|err| match err {\n                packed::iter::Error::Reference {\n                    invalid_line,\n                    line_number,\n                } => Error::PackedReference {\n                    invalid_line,\n                    line_number,\n                },\n                packed::iter::Error::Header { .. } => unreachable!(\"this one only happens on iteration creation\"),\n            })\n    }\n\n    fn convert_loose(&mut self, res: std::io::Result<(PathBuf, FullName)>) -> Result<Reference, Error> {\n        let buf = &mut self.buf;\n        let git_dir = self.git_dir;\n        let common_dir = self.common_dir;\n        let (refpath, name) = res.map_err(Error::Traversal)?;\n        std::fs::File::open(&refpath)\n            .and_then(|mut f| {\n                buf.clear();\n                f.read_to_end(buf)\n            })\n            .map_err(|err| Error::ReadFileContents {\n                source: err,\n                path: refpath.to_owned(),\n            })?;\n        loose::Reference::try_from_path(name, buf, self.object_hash)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-ref/src/store/file/overlay_iter.rs#L64-L100","documentation":"An `unreachable!()` panic in `convert_packed` within gix-ref's overlay ref iterator. When converting packed-refs iteration results, only per-line `InvalidLine`-style errors are expected; the `Header` error variant is supposed to surface exclusively when the packed-refs iterator is created (at buffer open), never mid-iteration. The panic fires if a header error is emitted during iteration.","triggerScenarios":"Iterating all refs of a repository (overlay of loose + packed refs, e.g. `repo.references()` or `gix ref list`) when the packed-refs file's header section turns out to be malformed but was not rejected at open time — e.g. a corrupted `packed-refs` file (truncated header, bad peeled-line placement) or a gix-ref version mismatch between open-time and iteration-time validation.","commonSituations":"Repositories with manually edited or partially written `packed-refs` files (interrupted `git pack-refs`, disk issues, sharing `.git` across tools/OSes), or older gix versions with inconsistent packed-refs header validation.","solutions":["Repair or regenerate the packed-refs file: run `git pack-refs --all` (after checking `git fsck`) or delete `.git/packed-refs` to fall back to loose refs","Restore the repository from a clean clone if refs data is corrupted","Upgrade gix / gix-ref so header errors are consistently rejected at iterator creation, and report the file content that triggered the panic upstream"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn packed_refs_look_sane(git_dir: &std::path::Path) -> bool {\n    match std::fs::read(git_dir.join(\"packed-refs\")) {\n        Ok(bytes) => bytes.is_empty() || bytes.starts_with(b\"# pack-refs\") || bytes.starts_with(b\"#\"),\n        Err(_) => true, // absent file is fine\n    }\n}","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| refs.all().collect::<Vec<_>>())\n    .map_err(|_| \"packed-refs corrupted mid-iteration; regenerate with git pack-refs\")?","preventionTips":["Never hand-edit .git/packed-refs; use git pack-refs to rewrite it","Run `git fsck` if a process writing packed-refs was interrupted","Avoid concurrent ref-writing tools on one repository","Keep gix-ref updated so header validation happens at open time consistently"],"tags":["rust","panic","packed-refs","refs","iteration"],"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"}