GitoxideLabs/gitoxide · error

initialized

Error message

initialized

What it means

`reduce_and_check_if_done` decrements the optional `remaining` counter with `.expect("initialized")` for each attribute matched. Like the sibling `remaining()`, this panics if the Outcome was never initialized for a search set when `fill_attributes` starts matching attributes.

Solutions

  1. Always let the search API create/initialize the Outcome before calling fill-style APIs
  2. Call the collection's initialization for the selected attribute set before matching
  3. Re-create the Outcome per search set; never reuse across searches
  4. Update gix-attributes to a version where initialization is enforced by construction

Example fix

// before
let mut outcome = Outcome::default();
fill_attributes(&mut outcome, ...);
// after
let mut outcome = collection.selected_attribute_set(...); // initializes remaining
fill_attributes(&mut outcome, ...);
Defensive patterns

Strategy: type-guard

Try / catch

let done = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
    fill_attributes(&mut outcome, ...)
}));

Prevention

When it happens

Trigger: Invoking the attribute matching pipeline (`fill_attributes`) with an Outcome whose `remaining` field is still `None` — i.e. the instance skipped the initialization step that assigns `remaining` from the selected attribute count.

Common situations: Hand-rolled integrations of `gix-attributes` search that construct Outcome directly; stale Outcome reuse across searches.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/e49cd786273fa142. Report an issue: GitHub.

Appendix: source

Thrown at gix-attributes/src/search/outcome.rs:232

    }
}

impl Outcome {
    /// Given a list of `attrs` by order, return true if at least one of them is not set
    pub(crate) fn has_unspecified_attributes(&self, mut attrs: impl Iterator<Item = AttributeId>) -> bool {
        attrs.any(|order| self.matches_by_id[order.0].r#match.is_none())
    }
    /// Return the amount of attributes haven't yet been found.
    ///
    /// If this number reaches 0, then the search can be stopped as there is nothing more to fill in.
    pub(crate) fn remaining(&self) -> usize {
        self.remaining
            .expect("BUG: instance must be initialized for each search set")
    }

    fn reduce_and_check_if_done(&mut self, attr: AttributeId) -> bool {
        if self.selected.is_empty() || self.selected.iter().any(|(_name, id)| *id == Some(attr)) {
            *self.remaining.as_mut().expect("initialized") -= 1;
        }
        self.is_done()
    }
}

impl std::fmt::Debug for Outcome {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        struct AsDisplay<'a>(&'a dyn std::fmt::Display);
        impl std::fmt::Debug for AsDisplay<'_> {
            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
                self.0.fmt(f)
            }
        }

        let mut dbg = f.debug_tuple("Outcome");
        if self.selected.is_empty() {
            for match_ in self.iter() {
                dbg.field(&AsDisplay(&match_.assignment));

View on GitHub (pinned to e73179060b)