{"record":{"id":"0a2b81e85e23c556","repo":"iOfficeAI/OfficeCLI","slug":"invalid-color-value-value-expected-6-digit-h-0a2b81","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'.{schemeHint}","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":772,"sourceCode":"                hex[0], hex[0], hex[1], hex[1], hex[2], hex[2], hex[3], hex[3],\n            });\n            var rgb = expanded[..6];\n            var alphaByte = Convert.ToByte(expanded.Substring(6, 2), 16);\n            if (alphaByte == 0xFF)\n                return (rgb, null);\n            return (rgb, (int)(alphaByte / 255.0 * 100000));\n        }\n\n        if (hex.Length != 6 || !hex.All(char.IsAsciiHexDigit))\n        {\n            // Scheme colors (accent1, dark2, hyperlink, …) are not handled\n            // here — callers that support theme colors must check\n            // IsSchemeColorName first and route to ThemeColor. Surface a\n            // hint instead of advertising support we don't provide.\n            var schemeHint = IsSchemeColorName(trimmedInput)\n                ? \" (scheme color names like 'accent1' must be set on properties that accept theme colors)\"\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'.\" + schemeHint);\n        }\n\n        return (hex, null);\n    }\n\n    // ==================== CJK Text Width Estimation ====================\n\n    /// <summary>\n    /// Returns true if the character is CJK ideograph, fullwidth, or CJK punctuation.\n    /// These characters occupy approximately 1em width (≈ fontSize) vs ~0.55em for Latin.\n    /// </summary>\n    public static bool IsCjkOrFullWidth(char ch)\n    {\n        // CJK Unified Ideographs\n        if (ch >= 0x4E00 && ch <= 0x9FFF) return true;","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ParseHelpers.cs#L754-L790","documentation":"Thrown by ParseHelpers.SanitizeColorForOoxml when, after trying named/rgb/hsl/transparent, #RRGGBBAA, AARRGGBB, 3- and 4- shorthand and 'auto', the remaining hex is not exactly 6 hex digits. The function returns (rgb6, alphaPercent) for srgbClr val. If the input is a recognized scheme color name, the message is extended with a schemeHint telling you to set it on a theme-color-aware property instead.","triggerScenarios":"Calling any srgbClr-based color setter routed through SanitizeColorForOoxml (Word/PPT fill, line, theme, gradient stops, drawing effects, chart series colors, axis) with a value that isn't 6-hex RGB, 8-hex, 3-/4-shorthand, named, rgb()/hsl(), 'transparent', or 'auto'. A scheme name like 'accent1' triggers the appended schemeHint.","commonSituations":"Passing a scheme color ('accent1','dk1','hyperlink') to a property that emits srgbClr (no themeColor handling); passing a 5- or 7-digit hex; passing 'rgb(300,0,0)'; misspelled color name; passing an RGBA 8-hex WITHOUT the '#' when you meant CSS RRGGBBAA (bare 8-hex is treated as AARRGGBB).","solutions":["For a literal color use one of: 'FF0000', '#FF0000', '#FF0000AA' (CSS alpha-last with #), '80FF0000' (AARRGGBB without #), 'F00', 'red', 'rgb(255,0,0)', 'transparent', 'auto'.","If the message carries the schemeHint, move that value to a property that accepts theme/scheme colors (the srgbClr path cannot store it).","Mind the # convention: with '#' an 8-hex value is RRGGBBAA (alpha last); without '#' it is AARRGGBB (alpha first)."],"exampleFix":"// before\ncolor=\"accent1\"   // on a non-theme-aware property\n// after\ncolor=\"4472C4\"     // literal hex, or route accent1 to a theme-color property","handlingStrategy":"validation","validationCode":"static bool IsAcceptableOoxmlColor(string value)\n{\n    try { var _ = OfficeCli.Core.ParseHelpers.SanitizeColorForOoxml(value); return true; }\n    catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { var (rgb, alpha) = ParseHelpers.SanitizeColorForOoxml(value); }\ncatch (ArgumentException ex) { /* surface error, especially the schemeHint if present */ }","preventionTips":["Remember the # convention: with '#', 8-hex is RRGGBBAA; without '#', it is AARRGGBB.","Use 6-hex RGB or named colors for opaque srgbClr values.","If the schemeHint appears, move the value to a theme-color-aware property."],"tags":["parsing","input-validation","color","hex","ooxml","word","pptx","chart","officecli"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}