GitoxideLabs/gitoxide · error · gix_config::value::Error

integer out of range

Error message

integer out of range

What it means

When validating the `pack.indexVersion` config value, the integer parsed but `to_decimal()` failed (value out of representable range), producing a `gix_config::value::Error` with message 'integer out of range'.

Solutions

  1. Set `pack.indexVersion` to 1 or 2 (the only valid index formats)
  2. Remove the invalid key to use the default version
  3. Use `git config pack.indexVersion 2`

Example fix

// before (.git/config)
[pack]
	indexVersion = 99999999999999999999
// after
[pack]
	indexVersion = 2
Defensive patterns

Strategy: validation

Validate before calling

fn valid_index_version(s: &str) -> bool {
    matches!(s, "1" | "2")
}
// check before writing pack.indexVersion to config

Try / catch

match gix::open(path) {
    Err(e) if e.to_string().contains("integer out of range") => {
        eprintln!("fix pack.indexVersion in config (must be 1 or 2): {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Setting `pack.indexVersion` to an integer whose magnitude exceeds the representable decimal range for the config integer type.

Common situations: Typos in huge numbers; misunderstanding that indexVersion only accepts 1 or 2 and writing a large number; copy-paste of sentinel values.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at gix/src/config/tree/sections/pack.rs:65

    }

    fn keys(&self) -> &[&dyn Key] {
        &[&Self::THREADS, &Self::INDEX_VERSION, &Self::COMPRESSION]
    }
}

mod validate {
    use crate::{bstr::BStr, config::tree::keys};

    #[derive(Clone, Copy)]
    pub struct IndexVersion;
    impl keys::Validate for IndexVersion {
        fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
            super::Pack::INDEX_VERSION.try_into_index_version(
                gix_config::Integer::try_from(value)
                    .and_then(|int| {
                        int.to_decimal()
                            .ok_or_else(|| gix_config::value::Error::new("integer out of range", value))
                    })
                    .map(Some),
            )?;
            Ok(())
        }
    }
}

View on GitHub (pinned to e73179060b)