GitoxideLabs/gitoxide · error
just added
Error message
just added
What it means
This panic comes from an `.expect("just added")` on `self.patterns.last_mut()` inside `add_patterns_file`. The invariant is that `add_patterns_file` returned `was_added == true`, which by contract means it just pushed a new pattern list onto `self.patterns`, so the last element must exist. The panic indicates the push/return contract of `gix_glob::search::add_patterns_file` was violated.
Solutions
- Update `gix-glob` and `gix-attributes` to matching released versions from the same workspace release
- Check for patched/vendor overrides of `gix-glob` in Cargo.toml [patch] sections and remove or update them
- Report the panic upstream with a repro of the attribute file being loaded
- As a workaround, load attribute patterns via `add_patterns_buffer` with manually read file contents
Example fix
// before (patched gix-glob with wrong contract)
fn add_patterns_file(...) -> io::Result<bool> { Ok(true) }
// after: use matched upstream versions
[dependencies]
gix-glob = "=0.17"
gix-attributes = "=0.22" Defensive patterns
Strategy: try-catch
Try / catch
// Rust panics cannot be caught per-call without a wrapper
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
search.add_patterns_file(source, follow, root, buf, &mut collection, true)
}));
if let Err(panic) = result { /* downgrade to an error / report bug */ } Prevention
- Keep all gix-* crates on versions from the same release
- Avoid [patch] overrides of gix-glob
- Load attribute files via buffer APIs if you need full control
When it happens
Trigger: Calling `Search::add_patterns_file` when `gix_glob::search::add_patterns_file` reports it added a list but the mutable borrow state is inconsistent — practically only reachable if the glob crate's add_patterns_file returns true without actually pushing, or if the patterns vec was concurrently/alienly mutated between the call and `last_mut()`.
Common situations: Effectively never hit by library users; it surfaces as a bug report when a mismatched version of `gix-glob` is vendored/patched and its `add_patterns_file` contract diverges from what `gix-attributes` expects.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- only value and unspecified are possible here
- parent-match assures this
- upper match already assured we only deal with blobs
- fixed size array with three items
- internal nodes have no object ID key
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/3cc56874fbc09962.
Report an issue: GitHub.
Appendix: source
Thrown at gix-attributes/src/search/attributes.rs:64
/// Update `collection` with newly added attribute names.
/// If a `root` is provided, it's not considered a global file anymore.
/// If `allow_macros` is `true`, macros will be processed like normal, otherwise they will be skipped entirely.
/// Returns `true` if the file was added, or `false` if it didn't exist.
pub fn add_patterns_file(
&mut self,
source: PathBuf,
follow_symlinks: bool,
root: Option<&Path>,
buf: &mut Vec<u8>,
collection: &mut MetadataCollection,
allow_macros: bool,
) -> std::io::Result<bool> {
// TODO: should `Pattern` trait use an instance as first argument to carry this information
// (so no `retain` later, it's slower than skipping)
let was_added =
gix_glob::search::add_patterns_file(&mut self.patterns, source, follow_symlinks, root, buf, Attributes)?;
if was_added {
let last = self.patterns.last_mut().expect("just added");
if !allow_macros {
last.patterns
.retain(|p| !matches!(p.value, Value::MacroAssignments { .. }));
}
collection.update_from_list(last);
}
Ok(was_added)
}
/// Add patterns as parsed from `bytes`, providing their `source` path and possibly their `root` path, the path they
/// are relative to. This also means that `source` is contained within `root` if `root` is provided.
/// If `allow_macros` is `true`, macros will be processed like normal, otherwise they will be skipped entirely.
pub fn add_patterns_buffer(
&mut self,
bytes: &[u8],
source: PathBuf,
root: Option<&Path>,
collection: &mut MetadataCollection,
allow_macros: bool,View on GitHub (pinned to e73179060b)