Hmbown/CodeWhale · error
Failed to update setting: invalid background_color
Error message
Failed to update setting: invalid background_color '{value}'. Expected #RRGGBB, RRGGBB, or default. What it means
The background_color setter normalizes input via normalize_hex_rgb_color, which accepts '#RRGGBB', bare 'RRGGBB', or the literal 'default'. Anything else yields this error naming the accepted formats.
Solutions
- Use a 6-digit hex value like '#1a2b3c' or '1a2b3c'
- Use the literal word 'default' to reset
- Convert named colors to their hex equivalent before setting
Example fix
// before /setting background_color darkblue // after /setting background_color #003366
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_bg_color(v: &str) -> bool {
let t = v.trim();
t.eq_ignore_ascii_case("default")
|| (t.strip_prefix('#').unwrap_or(t).len() == 6
&& t.strip_prefix('#').unwrap_or(t).chars().all(|c| c.is_ascii_hexdigit()))
} Try / catch
match set_background_color(value) {
Ok(c) => /* apply */,
Err(e) => eprintln!("{e:#}; use #RRGGBB, RRGGBB, or default"),
} Prevention
- Use a color picker that emits 6-digit hex
- Convert named colors to hex before setting
- Offer 'default' as an explicit reset option
When it happens
Trigger: Setting background_color to a value that is not a 6-digit hex RGB color (with or without '#') and not the string 'default' — e.g. 3-digit hex, named colors, rgba() strings.
Common situations: Trying CSS names like 'darkblue' or 'red'; using shorthand '#fff'; pasting 'rgb(0,0,0)'; extra whitespace is trimmed but embedded spaces still fail.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- agent profile provider cannot be empty
- agent profile provider must be a simple provider id
- api_key cannot be empty string
- approval_policy ' ' is not allowed by requirements ( )
- budget document_kind must be
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/8c67bc467c1f577d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/settings.rs:3002
}
fn normalize_optional_background_color(value: Option<&str>) -> Option<String> {
value.and_then(|raw| normalize_background_color_setting(raw).ok().flatten())
}
fn normalize_background_color_setting(value: &str) -> Result<Option<String>> {
let trimmed = value.trim();
if trimmed.is_empty()
|| matches!(
trimmed.to_ascii_lowercase().as_str(),
"default" | "none" | "reset" | "off"
)
{
return Ok(None);
}
normalize_hex_rgb_color(trimmed).map(Some).ok_or_else(|| {
anyhow::anyhow!(
"Failed to update setting: invalid background_color '{value}'. Expected #RRGGBB, RRGGBB, or default."
)
})
}
fn normalize_sidebar_focus(value: &str) -> &str {
match value.trim().to_ascii_lowercase().as_str() {
"pinned" | "visible" | "show" | "on" | "work" | "plan" | "todos" => "pinned",
"tasks" | "activity" | "live" | "running" => "tasks",
"agents" | "subagents" | "sub-agents" => "agents",
"context" => "context",
"sessions" | "sessions_rail" | "session_history" => "sessions",
"hidden" | "hide" | "closed" | "off" | "none" => "hidden",
_ => "auto",
}
}
fn is_false(value: &bool) -> bool {View on GitHub (pinned to 73e0f67d83)