{"record":{"id":"5244eb182a09fcea","repo":"GitoxideLabs/gitoxide","slug":"colors-are-specific-color-values-and-their-attribu","errorCode":null,"errorMessage":"Colors are specific color values and their attributes, like 'brightred', or 'blue'","messagePattern":"Colors are specific color values and their attributes, like 'brightred', or 'blue'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-config-value/src/color.rs","lineNumber":34,"sourceCode":"            if write_space.take().is_some() {\n                write!(f, \" \")?;\n            }\n            bg.fmt(f)?;\n            write_space = Some(());\n        }\n\n        if !self.attributes.is_empty() {\n            if write_space.take().is_some() {\n                write!(f, \" \")?;\n            }\n            self.attributes.fmt(f)?;\n        }\n        Ok(())\n    }\n}\n\nfn color_err(input: impl Into<BString>) -> Error {\n    Error::new(\n        \"Colors are specific color values and their attributes, like 'brightred', or 'blue'\",\n        input,\n    )\n}\n\nimpl TryFrom<&BStr> for Color {\n    type Error = Error;\n\n    fn try_from(s: &BStr) -> Result<Self, Self::Error> {\n        let s = std::str::from_utf8(s).map_err(|err| color_err(s).with_err(err))?;\n        enum ColorItem {\n            Value(Name),\n            Attr(Attribute),\n        }\n\n        let items = s.split_whitespace().filter_map(|s| {\n            if s.is_empty() {\n                return None;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-config-value/src/color.rs#L16-L52","documentation":"`Color` values parsed from git config must be a valid color name ('red', 'brightred', 'blue', ...), an ANSI number, or a color value combined with attributes like 'bold' or 'underline'. `color_err` raises this Error with the offending input when `TryFrom<&BStr> for Color` (and the `from_str` path) fails to match any known color or attribute token.","triggerScenarios":"`Color::try_from(&BStr)` or `Color::from_str` with input like 'redd', 'purplish', 'bright' alone, or an attribute spelled wrong ('bald' instead of 'bold').","commonSituations":"Hand-edited `[color]` sections in `.git/config`, e.g. `ui = purpul bold`, or scripts writing color values without validating against git's accepted names.","solutions":["Use a valid color name ('normal', 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', optionally 'bright'-prefixed) optionally followed by attributes ('bold', 'dim', 'ul', 'blink', 'reverse', 'italic', 'strike')","Use a numeric ANSI 0-255 color instead of a made-up name","Catch the Error and fall back to the default color setting"],"exampleFix":"// before (config)\n[color]\n    ui = purpul bold\n// after\n[color]\n    ui = brightred bold","handlingStrategy":"validation","validationCode":"fn is_valid_git_color(s: &str) -> bool {\n    let colors = [\"normal\",\"black\",\"red\",\"green\",\"yellow\",\"blue\",\"magenta\",\"cyan\",\"white\"];\n    let attrs = [\"bold\",\"dim\",\"ul\",\"blink\",\"reverse\",\"italic\",\"strike\"];\n    let mut toks = s.split_whitespace();\n    let c = toks.next().unwrap_or(\"\");\n    (colors.iter().any(|x| c.eq_ignore_ascii_case(x)) || c.parse::<u8>().is_ok())\n        && toks.all(|t| attrs.contains(&t))\n}","typeGuard":null,"tryCatchPattern":"let color = Color::try_from(value).unwrap_or_default();","preventionTips":["Only write color names from the git-documented set","Validate color config when accepting user input in tooling","Fall back to defaults instead of failing on exotic color strings"],"tags":["git","config","color","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}