Hmbown/CodeWhale · error
Failed to update setting: invalid {key} '{value}'. Expected
Error message
Failed to update setting: invalid {key} '{value}'. Expected a number from 10 to 100. What it means
Thrown by parse_percent_setting for percentage-style settings. The value is trimmed, one trailing '%' is stripped, parsed as f64, then required to lie within 10.0..=100.0. Parse failures and out-of-range values bail with the identical message, so the cause is ambiguous from the text alone.
Source
Thrown at crates/tui/src/settings.rs:2599
let parsed = value
.trim()
.parse::<u16>()
.map_err(|_| anyhow::anyhow!("Invalid {key} '{value}': expected {min}-{max}"))?;
if !(min..=max).contains(&parsed) {
anyhow::bail!("Invalid {key} '{value}': expected {min}-{max}");
}
Ok(parsed)
}
fn parse_percent_setting(key: &str, value: &str) -> Result<f64> {
let trimmed = value.trim().trim_end_matches('%').trim();
let percent = trimmed.parse::<f64>().map_err(|_| {
anyhow::anyhow!(
"Failed to update setting: invalid {key} '{value}'. Expected a number from 10 to 100."
)
})?;
if !(10.0..=100.0).contains(&percent) {
anyhow::bail!(
"Failed to update setting: invalid {key} '{value}'. Expected a number from 10 to 100."
);
}
Ok(percent)
}
fn normalize_mention_menu_behavior(value: &str) -> Result<String> {
match value.trim().to_ascii_lowercase().as_str() {
"fuzzy" | "default" => Ok("fuzzy".to_string()),
"browser" | "browse" | "file-browser" | "file_browser" => Ok("browser".to_string()),
_ => {
anyhow::bail!(
"Failed to update setting: invalid mention_menu_behavior '{value}'. Expected: fuzzy, browser."
)
}
}
}
View on GitHub (pinned to 0c42157ee5)
Solutions
- Send a number between 10 and 100 inclusive; a single trailing % is optional.
- Use a dot for decimals, not a comma.
- If you genuinely need below 10%, that is out of contract by design; use 10 or reconsider which setting you need.
- Pre-validate in the caller: trim, strip one %, parse f64, range-check 10..=100.
Example fix
# before :set context_percent 5% # after :set context_percent 10%
Defensive patterns
Strategy: validation
Validate before calling
fn valid_percent(v: &str) -> bool {
let t = v.trim().trim_end_matches('%').trim();
matches!(t.parse::<f64>(), Ok(p) if (10.0..=100.0).contains(&p))
} Try / catch
match parse_percent_setting(key, value) {
Err(err) if err.to_string().contains("number from 10 to 100") => clamp_or_reprompt(),
other => other?,
} Prevention
- Strip one trailing '%' and use a dot decimal before submitting.
- Treat sub-10 percentages as out of contract rather than retrying variations.
- Validate percent fields in config UIs with the same 10..=100 window.
When it happens
Trigger: ':set context_percent 5' (below 10), ':set context_percent 150' (above 100), ':set context_percent abc', or a double percent '10%%' where only one trailing % is stripped and the second breaks the f64 parse.
Common situations: Users trying to reserve tiny contexts (5%), values above 100 assuming oversubscription works, locale-style decimal commas ('12,5'), and trailing junk after the number ('50 x').
Related errors
- Invalid {key} '{value}': expected {min}-{max}
- Failed to update setting: invalid ocean treatment '{value}'.
- Failed to update setting: invalid focus texture '{value}'. E
- Failed to update setting: invalid work surface placement '{v
- Failed to parse boolean '{value}': expected on/off, true/fal
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/91b756c6d7bf8720.
Report an issue: GitHub.