GitoxideLabs/gitoxide · error
Booleans need to be 'no', 'off', 'false', '' or 'yes'…
Error message
Booleans need to be 'no', 'off', 'false', '' or 'yes', 'on', 'true' or any number
What it means
gix-config-value's `Boolean` type only accepts the git-config boolean spellings: 'no', 'off', 'false', '' (empty), 'yes', 'on', 'true', or a bare number (any non-zero number is true, 0 is false). `bool_err` builds this Error with the offending input embedded whenever parsing falls through all of those cases. It is thrown from the `TryFrom<&BStr>` / `TryFrom<OsString>` conversions that callers use to read a boolean out of git configuration.
Solutions
- Fix the config value to one of: 'no', 'off', 'false', '' or 'yes', 'on', 'true' or a number
- Normalize/trim the string in your code before calling `try_from` (the parser does not trim whitespace)
- Handle the Error and fall back to a default boolean instead of propagating it
Example fix
// before (config)
[alias]
autosetup = maybe
// after
[alias]
autosetup = true Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_git_bool(s: &str) -> bool {
matches!(s.trim(), "no"|"off"|"false"|""|"yes"|"on"|"true") || s.trim().parse::<i64>().is_ok()
} Try / catch
let b = Boolean::try_from(value).unwrap_or(Boolean::new(false));
Prevention
- Trim and lowercase config strings before parsing booleans
- Validate user-edited config files at load time
- Provide defaults with unwrap_or for optional flags
When it happens
Trigger: Calling `Boolean::try_from(&BStr)` or `Boolean::try_from(OsString)` with input that is none of the accepted literals: e.g. `"maybe"`, `"TRUE "` (whitespace not stripped by caller), `"enabled"`, or misspelled values read from a config file.
Common situations: Users hand-editing `.git/config` or `~/.gitconfig` type something like `publishMaybe = maybe` or `flag = onn`; tooling then reads the key via gix and gets this error instead of silently defaulting.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Colors are specific color values and their attributes, like…
- Integers needs to be positive or negative numbers which may…
- The remote has no URL
- Without refspecs there is nothing to show here. Add…
- (re-raised revision-spec parse error via bail!(err))
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/66244f73d8c95927.
Report an issue: GitHub.
Appendix: source
Thrown at gix-config-value/src/boolean.rs:8
use std::{borrow::Cow, ffi::OsString, fmt::Display};
use bstr::{BStr, BString, ByteSlice};
use crate::{Boolean, Error};
fn bool_err(input: impl Into<BString>) -> Error {
Error::new(
"Booleans need to be 'no', 'off', 'false', '' or 'yes', 'on', 'true' or any number",
input,
)
}
impl TryFrom<OsString> for Boolean {
type Error = Error;
fn try_from(value: OsString) -> Result<Self, Self::Error> {
let value = gix_path::os_str_into_bstr(&value)
.map_err(|_| Error::new("Illformed UTF-8", std::path::Path::new(&value).display().to_string()))?;
Self::try_from(value)
}
}
/// # Warning
///
/// The direct usage of `try_from("string")` is discouraged as it will produce the wrong result for valuesView on GitHub (pinned to e73179060b)