{"record":{"id":"aec01fc12a249e20","repo":"GitoxideLabs/gitoxide","slug":"one-of-our-bases-contains-the-path","errorCode":null,"errorMessage":"one of our bases contains the path","messagePattern":"one of our bases contains the path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"gix-ref/src/store/file/overlay_iter.rs","lineNumber":106,"sourceCode":"        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)\n            .map_err(|err| {\n                let relative_path = refpath\n                    .strip_prefix(git_dir)\n                    .ok()\n                    .or_else(|| common_dir.and_then(|common_dir| refpath.strip_prefix(common_dir).ok()))\n                    .expect(\"one of our bases contains the path\");\n                Error::ReferenceCreation {\n                    source: err,\n                    relative_path: relative_path.into(),\n                }\n            })\n            .map(Into::into)\n            .map(|r| self.strip_namespace(r))\n    }\n}\n\nimpl Iterator for LooseThenPacked<'_, '_> {\n    type Item = Result<Reference, Error>;\n\n    fn next(&mut self) -> Option<Self::Item> {\n        fn advance_to_non_private(iter: &mut Peekable<SortedLoosePaths>) {\n            while let Some(Ok((_path, name))) = iter.peek() {\n                if name.category().is_some_and(|cat| cat.is_worktree_private()) {\n                    iter.next();","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-ref/src/store/file/overlay_iter.rs#L88-L124","documentation":"When converting a loose reference file into a `Reference` fails during overlay iteration, the error path computes a `relative_path` by stripping the git-dir or common-dir prefix from the file path. The `expect(\"one of our bases contains the path\")` asserts the ref file being iterated always lives under one of those two roots. A panic means iteration produced a path outside both bases.","triggerScenarios":"Iterating references where a loose ref file path (`refpath`) is neither under the git-dir nor the common-dir — an internal inconsistency in root setup, or a failed `ReferenceCreation` error path caused by an unreadable/corrupt loose ref file whose path was mis-derived.","commonSituations":"Seen (if at all) around odd repository setups: symlinked git-dirs, `GIT_COMMON_DIR` manipulation, or manual edits to `.git` layout. The underlying `ReferenceCreation` failure (corrupt ref file) is the real trigger; the panic is a secondary bug.","solutions":["Inspect the loose ref files in `.git/refs` and `$GIT_COMMON_DIR/refs` for corruption or odd permissions","Check for `GIT_COMMON_DIR` env overrides or symlinked git-dir layouts that confuse root detection","Fix or remove the corrupt ref file; run `git fsck` for reference-level validation","If paths are all normal and it still panics, file a gix-ref bug with the repository layout"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure loose ref files live under git-dir or common-dir before custom iteration\nassert!(refpath.starts_with(git_dir) || refpath.starts_with(common_dir));","typeGuard":null,"tryCatchPattern":"// Panic path; run fsck and repair instead of attempting recovery\n// git fsck --strict && rm/fix corrupt refs, then re-run iteration","preventionTips":["Run `git fsck` on repositories with hand-edited or symlinked ref layouts","Avoid `GIT_COMMON_DIR` overrides and symlinked git-dirs unless necessary","Fix corrupt loose ref files promptly; the panic is a secondary failure","Report unexpected reproductions to gix-ref with the full layout"],"tags":["rust","panic","gix-ref","loose-ref","corruption"],"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"}