{"record":{"id":"34ce5372ef393dbb","repo":"iOfficeAI/OfficeCLI","slug":"invalid-color-value-value-expected-6-digit-h","errorCode":null,"errorMessage":"Invalid color value: '{value}'. Expected 6-digit hex RGB (e.g. FF0000), 8-digit AARRGGBB (e.g. 80FF0000), 3-digit shorthand (e.g. F00) or 4-digit #RGBA shorthand (e.g. F00A), named color (e.g. red), rgb()/rgba()/hsl()/hsla() notation, or 'transparent'.","messagePattern":"Invalid color value: '(.+?)'\\. Expected 6-digit hex RGB \\(e\\.g\\. FF0000\\), 8-digit AARRGGBB \\(e\\.g\\. 80FF0000\\), 3-digit shorthand \\(e\\.g\\. F00\\) or 4-digit #RGBA shorthand \\(e\\.g\\. F00A\\), named color \\(e\\.g\\. red\\), rgb\\(\\)/rgba\\(\\)/hsl\\(\\)/hsla\\(\\) notation, or 'transparent'\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/ParseHelpers.cs","lineNumber":602,"sourceCode":"            // (the explicit `transparent` keyword or 8-digit #00000000 form\n            // exists for that intent and is unambiguous).\n            hex = new string(new[]\n            {\n                hex[0], hex[0], hex[1], hex[1], hex[2], hex[2], hex[3], hex[3],\n            });\n        }\n        if (hex.Length == 6 && hex.All(char.IsAsciiHexDigit))\n            return \"FF\" + hex;\n        if (hex.Length == 8 && hex.All(char.IsAsciiHexDigit))\n        {\n            // CONSISTENCY(color-input-form): #-prefixed 8-hex is CSS RRGGBBAA\n            // (alpha last); bare 8-hex stays in OOXML AARRGGBB (alpha first).\n            // Mirrors SanitizeColorForOoxml.\n            if (hadHashPrefix)\n                return hex.Substring(6, 2) + hex[..6];\n            return hex;\n        }\n        throw new ArgumentException(\n            $\"Invalid color value: '{value}'. Expected 6-digit hex RGB (e.g. FF0000), \" +\n            $\"8-digit AARRGGBB (e.g. 80FF0000), 3-digit shorthand (e.g. F00) or 4-digit #RGBA shorthand (e.g. F00A), \" +\n            $\"named color (e.g. red), rgb()/rgba()/hsl()/hsla() notation, or 'transparent'.\");\n    }\n\n    /// <summary>\n    /// Word/PPT theme scheme color names (ECMA-376 §17.18.97 / §20.1.10.46).\n    /// Keep lowercase — input is matched case-insensitively but the canonical\n    /// OOXML serialization (and downstream readback) is lowercase.\n    /// </summary>\n    public static readonly HashSet<string> SchemeColorNames = new(StringComparer.OrdinalIgnoreCase)\n    {\n        \"dark1\", \"light1\", \"dark2\", \"light2\",\n        \"accent1\", \"accent2\", \"accent3\", \"accent4\", \"accent5\", \"accent6\",\n        \"hyperlink\", \"followedHyperlink\",\n        // Extra variants seen in OOXML: text1/text2/background1/background2 alias dark/light.\n        \"text1\", \"text2\", \"background1\", \"background2\",\n        // BUG-R6-06: alternate Word theme color aliases (windowText / windowBackground)","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ParseHelpers.cs#L584-L620","documentation":"Thrown by ParseHelpers.NormalizeArgbColor as the final fallthrough when the input matches none of the accepted color forms. The function returns an 8-char AARRGGBB string and accepts: named colors, rgb()/rgba()/hsl()/hsla(), 'transparent', 6-hex RGB, 8-hex AARRGGBB (or #RRGGBBAA), 3-hex shorthand, and #RGBA shorthand (non-zero alpha). Inner whitespace and any other shape are rejected.","triggerScenarios":"Calling a property that routes through NormalizeArgbColor (Excel cell/rich-text-run/conditional-format/sparkline colors, ExcelStyleManager hex) with a value that is none of the accepted forms — e.g. 'accent1' (a scheme color, not handled here), a 5-digit hex, '#FF 0000' (inner space), 'rgb(300,0,0)' out of range, or a misspelled color name.","commonSituations":"Trying to set a theme/scheme color (accent1, dark2, hyperlink) on a property that only accepts literal colors — these must go on theme-color-aware properties; copying a CSS color with inner whitespace; typos in named colors ('redd'); truncated hex.","solutions":["Use a supported literal form: 'FF0000', '#FF0000', 'F00', '80FF0000', '#FF0000AA', 'red', 'rgb(255,0,0)', 'transparent'.","For scheme/theme colors (accent1, dark2, hyperlink, …) use a property that accepts theme colors — NormalizeArgbColor does not resolve them.","Remove inner whitespace from the value (outer whitespace is auto-trimmed, inner is not)."],"exampleFix":"// before\nfillColor=\"accent1\"\n// after\nfillColor=\"FF0000\"   // or use a theme-color-aware property for accent1","handlingStrategy":"validation","validationCode":"// Cheap pre-check: normalize then confirm 8 hex digits came back, or it is a known literal form.\nstatic bool IsAcceptableArgbColor(string value)\n{\n    try { return System.Text.RegularExpressions.Regex.IsMatch(\n        OfficeCli.Core.ParseHelpers.NormalizeArgbColor(value), @\"^[0-9A-F]{8}$\"); }\n    catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { var argb = ParseHelpers.NormalizeArgbColor(value); }\ncatch (ArgumentException ex) { /* report invalid color to user, keep prior value */ }","preventionTips":["Use supported literal forms (hex, named, rgb(), transparent).","Route scheme/theme colors to theme-color-aware properties, not NormalizeArgbColor.","Avoid inner whitespace in color values."],"tags":["parsing","input-validation","color","hex","ooxml","excel","officecli"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}