GitoxideLabs/gitoxide · error
Integer overflow
Error message
Integer overflow
What it means
`File::integer_filter_by()` successfully parsed the raw config value into a gix-config `Integer`, but `to_decimal()` — which converts the value with its unit multiplier into a plain decimal — failed, meaning the value overflows the target integer type (e.g. '10g' scaled beyond i64 range). The code raises a value::Error 'Integer overflow' carrying the original bytes.
Solutions
- Reduce the value or use a larger suffix-appropriate magnitude that fits in the target signed type
- Use the raw `Integer` and inspect it yourself instead of demanding a decimal
- Catch the value::Error and fall back to a sensible default
Example fix
// before (config)
[pack]
windowMemory = 18446744073709551615
// after
[pack]
windowMemory = 4g Defensive patterns
Strategy: try-catch
Validate before calling
fn fits_decimal(s: &BStr) -> bool {
Integer::try_from(s).ok().and_then(|i| i.to_decimal()).is_some()
} Try / catch
match file.integer(key) {
Ok(v) => v,
Err(e) if e.to_string().contains("Integer overflow") => DEFAULT_VALUE,
Err(e) => return Err(e),
} Prevention
- Keep byte-count config values well below i64::MAX after suffix scaling
- Prefer explicit small suffixes (k/m) for large values
- Test config parsing against extreme values in CI
When it happens
Trigger: Calling `file.integer(key)` / `integer_filter_by(...)` where the stored value with its k/m/g suffix, after multiplication, exceeds the numeric range, e.g. `size = 18446744073709551616` or a huge 'g'-suffixed value.
Common situations: Users copying 64-bit-plus byte counts into config keys like `core.bigFileThreshold` or `pack.packSizeLimit`, or config written by other tools expecting unsigned 128-bit semantics.
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
- Integers needs to be positive or negative numbers which may…
- The remote has no URL
- Without refspecs there is nothing to show here. Add…
- undo metadata contains an unknown section
- Booleans need to be 'no', 'off', 'false', '' or 'yes'…
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/06bc1c4a77868981.
Report an issue: GitHub.
Appendix: source
Thrown at gix-config/src/file/access/comfort.rs:186
self.integer_filter_by(key.section_name, key.subsection_name, key.value_name, filter)
}
/// Like [`integer_by()`](File::integer_by()), but the section containing the returned value must pass `filter` as well.
pub fn integer_filter_by(
&self,
section_name: impl AsRef<str>,
subsection_name: impl AsBStrOpt,
value_name: impl AsRef<str>,
filter: impl FnMut(&Metadata) -> bool,
) -> Result<Option<i64>, value::Error> {
let Some(int) = self
.raw_value_filter_by(section_name, subsection_name, value_name, filter)
.ok()
else {
return Ok(None);
};
crate::Integer::try_from(BStr::new(&int))
.and_then(|b| b.to_decimal().ok_or_else(|| value::Error::new("Integer overflow", int)))
.map(Some)
}
/// Like [`strings_by()`](File::strings_by()), but suitable for statically known `key`s like `remote.origin.url`.
pub fn strings(&self, key: impl AsKey) -> Option<Vec<BString>> {
let key = key.try_as_key()?;
self.strings_by(key.section_name, key.subsection_name, key.value_name)
}
/// Similar to [`values_by(…)`](File::values_by()) but returning strings if at least one of them was found.
pub fn strings_by(
&self,
section_name: impl AsRef<str>,
subsection_name: impl AsBStrOpt,
value_name: impl AsRef<str>,
) -> Option<Vec<BString>> {
self.raw_values_by(section_name, subsection_name, value_name).ok()
}View on GitHub (pinned to e73179060b)